| 1 |
#include <gtest/gtest.h> // for AssertHelper, EXPECT_EQ, etc |
| 2 |
#include <stk_mesh/base/GetEntities.hpp> |
| 3 |
#include <stk_mesh/base/BulkData.hpp> |
| 4 |
#include <stk_mesh/base/MetaData.hpp> // for MetaData |
| 5 |
#include <stk_mesh/base/SkinBoundary.hpp> |
| 6 |
#include <stk_mesh/base/SideSetUtil.hpp> |
| 7 |
#include <stk_mesh/base/SidesetUpdater.hpp> |
| 8 |
#include <stk_mesh/base/DestroyElements.hpp> |
| 9 |
#include <stk_mesh/baseImpl/MeshImplUtils.hpp> |
| 10 |
#include <stk_mesh/baseImpl/elementGraph/ElemElemGraphImpl.hpp> |
| 11 |
#include <stk_unit_test_utils/ioUtils.hpp> |
| 12 |
#include <stk_unit_test_utils/MeshFixture.hpp> |
| 13 |
#include <stk_io/IossBridge.hpp> |
| 14 |
#include <stk_io/StkMeshIoBroker.hpp> |
| 15 |
#include <stk_io/InputFile.hpp> |
| 16 |
#include <stk_unit_test_utils/BuildMesh.hpp> |
| 17 |
#include <stk_unit_test_utils/TextMesh.hpp> |
| 18 |
#include <stk_mesh/base/FEMHelpers.hpp> |
| 19 |
#include <stk_mesh/base/SideSetUtil.hpp> |
| 20 |
#include "TestElemElemGraphUtils.hpp" |
| 21 |
|
| 22 |
namespace { |
| 23 |
using stk::unit_test_util::build_mesh; |
| 24 |
|
| 25 |
void check_ordinal_and_permutation(const stk::mesh::BulkData& bulk, |
| 26 |
stk::mesh::Entity elem, |
| 27 |
stk::mesh::EntityRank rank, |
| 28 |
const stk::mesh::EntityVector& sideNodes, |
| 29 |
stk::mesh::ConnectivityOrdinal expectedSideOrdinal, |
| 30 |
stk::mesh::Permutation expectedPerm) |
| 31 |
{ |
| 32 |
stk::mesh::OrdinalAndPermutation ordPerm = |
| 33 |
stk::mesh::get_ordinal_and_permutation(bulk, elem, rank, sideNodes); |
| 34 |
EXPECT_EQ(expectedSideOrdinal, ordPerm.first); |
| 35 |
EXPECT_EQ(expectedPerm, ordPerm.second); |
| 36 |
} |
| 37 |
|
| 38 |
void move_elems_from_block_to_block(stk::mesh::BulkData& bulk, |
| 39 |
const std::vector<stk::mesh::EntityId>& elemIDs, |
| 40 |
const std::string& fromBlockName, |
| 41 |
const std::string& toBlockName) |
| 42 |
{ |
| 43 |
stk::mesh::Part& fromBlock = *bulk.mesh_meta_data().get_part(fromBlockName); |
| 44 |
stk::mesh::Part& toBlock = *bulk.mesh_meta_data().get_part(toBlockName); |
| 45 |
|
| 46 |
stk::mesh::EntityVector elems; |
| 47 |
for(stk::mesh::EntityId elemID : elemIDs) { |
| 48 |
stk::mesh::Entity elem = bulk.get_entity(stk::topology::ELEM_RANK, elemID); |
| 49 |
STK_ThrowRequireMsg(bulk.is_valid(elem), "Failed to find element with ID="<<elemID); |
| 50 |
elems.push_back(elem); |
| 51 |
} |
| 52 |
|
| 53 |
bulk.batch_change_entity_parts(elems, stk::mesh::PartVector{&toBlock}, stk::mesh::PartVector{&fromBlock}); |
| 54 |
} |
| 55 |
|
| 56 |
void copy_elems_from_block_to_block(stk::mesh::BulkData& bulk, |
| 57 |
const std::vector<stk::mesh::EntityId>& elemIDs, |
| 58 |
const std::string& /*fromBlockName*/, |
| 59 |
const std::string& toBlockName) |
| 60 |
{ |
| 61 |
stk::mesh::Part& toBlock = *bulk.mesh_meta_data().get_part(toBlockName); |
| 62 |
|
| 63 |
stk::mesh::EntityVector elems; |
| 64 |
for(stk::mesh::EntityId elemID : elemIDs) { |
| 65 |
stk::mesh::Entity elem = bulk.get_entity(stk::topology::ELEM_RANK, elemID); |
| 66 |
STK_ThrowRequireMsg(bulk.is_valid(elem), "Failed to find element with ID="<<elemID); |
| 67 |
elems.push_back(elem); |
| 68 |
} |
| 69 |
|
| 70 |
bulk.batch_change_entity_parts(elems, stk::mesh::PartVector{&toBlock}, stk::mesh::PartVector{}); |
| 71 |
} |
| 72 |
|
| 73 |
void create_sides_between_blocks(stk::mesh::BulkData& bulk, |
| 74 |
const std::string& block1Name, |
| 75 |
const std::string& block2Name, |
| 76 |
const std::string& sidePartName) |
| 77 |
{ |
| 78 |
stk::mesh::Part& block1 = *bulk.mesh_meta_data().get_part(block1Name); |
| 79 |
stk::mesh::Part& block2 = *bulk.mesh_meta_data().get_part(block2Name); |
| 80 |
stk::mesh::Part& sidePart = *bulk.mesh_meta_data().get_part(sidePartName); |
| 81 |
|
| 82 |
stk::mesh::Selector blockSelector = block1 | block2; |
| 83 |
stk::mesh::create_interior_block_boundary_sides(bulk, blockSelector, stk::mesh::PartVector{&sidePart}); |
| 84 |
} |
| 85 |
|
| 86 |
void move_sides_between_blocks_into_sideset_part(stk::mesh::BulkData& bulk, |
| 87 |
const std::string& block1Name, |
| 88 |
const std::string& block2Name, |
| 89 |
const std::string& sidePartName) |
| 90 |
{ |
| 91 |
stk::mesh::Part& block1 = *bulk.mesh_meta_data().get_part(block1Name); |
| 92 |
stk::mesh::Part& block2 = *bulk.mesh_meta_data().get_part(block2Name); |
| 93 |
stk::mesh::Part& sidePart = *bulk.mesh_meta_data().get_part(sidePartName); |
| 94 |
|
| 95 |
stk::mesh::Selector betweenBlocks = block1 & block2; |
| 96 |
stk::mesh::EntityVector sidesBetweenBlocks; |
| 97 |
stk::mesh::get_selected_entities(betweenBlocks, bulk.buckets(stk::topology::FACE_RANK), sidesBetweenBlocks); |
| 98 |
|
| 99 |
bulk.batch_change_entity_parts(sidesBetweenBlocks, stk::mesh::PartVector{&sidePart}, stk::mesh::PartVector{}); |
| 100 |
} |
| 101 |
|
| 102 |
void create_sideset(stk::mesh::BulkData& bulk, |
| 103 |
const std::string& surfacePartName, |
| 104 |
const std::string& blockPartName) |
| 105 |
{ |
| 106 |
stk::mesh::Part& blockPart = *bulk.mesh_meta_data().get_part(blockPartName); |
| 107 |
stk::mesh::Part& surfacePart = *bulk.mesh_meta_data().get_part(surfacePartName); |
| 108 |
|
| 109 |
bulk.mesh_meta_data().set_surface_to_block_mapping(&surfacePart, stk::mesh::ConstPartVector{&blockPart}); |
| 110 |
bulk.create_sideset(stk::mesh::get_sideset_parent(surfacePart)); |
| 111 |
} |
| 112 |
|
| 113 |
void check_sideset_elems(const stk::mesh::BulkData& bulk, |
| 114 |
const std::string surfacePartName, |
| 115 |
const std::vector<stk::mesh::EntityId>& elemIDs) |
| 116 |
{ |
| 117 |
EXPECT_EQ(1u, bulk.get_number_of_sidesets()); |
| 118 |
|
| 119 |
stk::mesh::Part& surfacePart = *bulk.mesh_meta_data().get_part(surfacePartName); |
| 120 |
const stk::mesh::SideSet& sideset = bulk.get_sideset(surfacePart); |
| 121 |
ASSERT_EQ(elemIDs.size(), sideset.size()); |
| 122 |
|
| 123 |
for(size_t i=0; i<elemIDs.size(); ++i) { |
| 124 |
EXPECT_EQ(elemIDs[i], bulk.identifier(sideset[i].element)); |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
void load_mesh_with_specified_splitting(stk::mesh::BulkData &bulk, const std::string &filename, Ioss::SurfaceSplitType splitType) |
| 129 |
{ |
| 130 |
stk::io::StkMeshIoBroker stkIo; |
| 131 |
stkIo.set_bulk_data(bulk); |
| 132 |
size_t inputIdx = stkIo.add_mesh_database(filename, stk::io::READ_MESH); |
| 133 |
stk::io::InputFile &inputFile = stkIo.get_mesh_database(inputIdx); |
| 134 |
inputFile.set_surface_split_type(splitType); |
| 135 |
|
| 136 |
stkIo.create_input_mesh(); |
| 137 |
stkIo.add_all_mesh_fields_as_input_fields(); |
| 138 |
stkIo.populate_bulk_data(); |
| 139 |
} |
| 140 |
|
| 141 |
void write_mesh_with_specified_splitting(stk::mesh::BulkData &bulk, const std::string &filename, Ioss::SurfaceSplitType splitType) |
| 142 |
{ |
| 143 |
stk::io::StkMeshIoBroker stkIo; |
| 144 |
stkIo.set_bulk_data(bulk); |
| 145 |
|
| 146 |
size_t outputIdx = stkIo.create_output_mesh(filename, stk::io::WRITE_RESULTS); |
| 147 |
Ioss::Region* ioRegion = stkIo.get_output_ioss_region(outputIdx).get(); |
| 148 |
|
| 149 |
Ioss::DatabaseIO *db = ioRegion->get_database(); |
| 150 |
assert(db != nullptr); |
| 151 |
db->set_surface_split_type(splitType); |
| 152 |
|
| 153 |
stkIo.write_output_mesh(outputIdx); |
| 154 |
} |
| 155 |
|
| 156 |
void create_two_elem_block_mesh_with_spanning_sidesets(const std::string& filename) |
| 157 |
{ |
| 158 |
const int dim = 3; |
| 159 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(dim, MPI_COMM_WORLD); |
| 160 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 161 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 162 |
|
| 163 |
|
| 164 |
const std::string meshDesc = "generated:1x1x2|sideset:xX"; |
| 165 |
|
| 166 |
stk::mesh::Part& block_2 = meta.declare_part("block_2", stk::topology::ELEM_RANK); |
| 167 |
stk::mesh::set_topology(block_2, stk::topology::HEX_8); |
| 168 |
meta.set_part_id(block_2, 2); |
| 169 |
stk::io::put_io_part_attribute(block_2); |
| 170 |
|
| 171 |
load_mesh_with_specified_splitting(bulk, meshDesc, Ioss::SPLIT_BY_TOPOLOGIES); |
| 172 |
|
| 173 |
stk::mesh::Part* block_1 = meta.get_part("block_1"); |
| 174 |
EXPECT_TRUE(block_1 != nullptr); |
| 175 |
|
| 176 |
stk::mesh::Part* surface_1 = meta.get_part("surface_1"); |
| 177 |
stk::mesh::Part* surface_2 = meta.get_part("surface_2"); |
| 178 |
stk::mesh::Part* surface_1_quad4 = meta.get_part("surface_1_quad4"); |
| 179 |
stk::mesh::Part* surface_2_quad4 = meta.get_part("surface_2_quad4"); |
| 180 |
|
| 181 |
EXPECT_TRUE(surface_1 != nullptr); |
| 182 |
EXPECT_TRUE(surface_2 != nullptr); |
| 183 |
EXPECT_TRUE(surface_1_quad4 != nullptr); |
| 184 |
EXPECT_TRUE(surface_2_quad4 != nullptr); |
| 185 |
|
| 186 |
std::vector<const stk::mesh::Part*> touchingParts{block_1, &block_2}; |
| 187 |
|
| 188 |
meta.set_surface_to_block_mapping(surface_1, touchingParts); |
| 189 |
meta.set_surface_to_block_mapping(surface_2, touchingParts); |
| 190 |
meta.set_surface_to_block_mapping(surface_1_quad4, touchingParts); |
| 191 |
meta.set_surface_to_block_mapping(surface_2_quad4, touchingParts); |
| 192 |
|
| 193 |
bulk.modification_begin(""); |
| 194 |
stk::mesh::Entity elem2 = bulk.get_entity(stk::topology::ELEM_RANK, 2); |
| 195 |
if(bulk.is_valid(elem2) && bulk.bucket(elem2).owned()) { |
| 196 |
stk::mesh::PartVector addParts = {&block_2}; |
| 197 |
stk::mesh::PartVector removeParts = {block_1}; |
| 198 |
|
| 199 |
bulk.change_entity_parts(elem2, addParts, removeParts); |
| 200 |
} |
| 201 |
bulk.modification_end(); |
| 202 |
|
| 203 |
write_mesh_with_specified_splitting(bulk, filename, Ioss::SPLIT_BY_ELEMENT_BLOCK); |
| 204 |
} |
| 205 |
} |
| 206 |
|
| 207 |
TEST(SkinBoundary, check_interior_shared_shell_side) |
| 208 |
{ |
| 209 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 2) { GTEST_SKIP(); } |
| 210 |
|
| 211 |
std::unique_ptr<stk::mesh::BulkData> bulkPtr = stk::mesh::MeshBuilder(MPI_COMM_WORLD) |
| 212 |
.set_spatial_dimension(3) |
| 213 |
.set_aura_option(stk::mesh::BulkData::NO_AUTO_AURA) |
| 214 |
.create(); |
| 215 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 216 |
stk::mesh::Part& boundaryPart = meta.declare_part("boundaryPart", meta.side_rank()); |
| 217 |
std::string meshDesc = "1,10098,TET_4, 1,2,3,4, block_1\n" |
| 218 |
"0,320234,SHELL_TRI_3, 1,3,4, block_2|sideset:name=surface_1; data=10098,3"; |
| 219 |
|
| 220 |
std::vector<double> coords = {0,0,0, 0,1,0, 1,0,0, 1,1,1}; |
| 221 |
|
| 222 |
stk::unit_test_util::setup_text_mesh(*bulkPtr, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 223 |
|
| 224 |
stk::mesh::Entity sharedSide = bulkPtr->get_entity(meta.side_rank(), 100983); |
| 225 |
ASSERT_TRUE(bulkPtr->is_valid(sharedSide)); |
| 226 |
ASSERT_TRUE(bulkPtr->bucket(sharedSide).shared()); |
| 227 |
|
| 228 |
int owner = bulkPtr->parallel_owner_rank(sharedSide); |
| 229 |
int otherProc = 1 - owner; |
| 230 |
stk::mesh::EntityProcVec entitiesToChange; |
| 231 |
if (owner == bulkPtr->parallel_rank()) { |
| 232 |
entitiesToChange = {stk::mesh::EntityProc(sharedSide, otherProc)}; |
| 233 |
} |
| 234 |
bulkPtr->change_entity_owner(entitiesToChange); |
| 235 |
|
| 236 |
stk::mesh::create_interior_block_boundary_sides(*bulkPtr, meta.universal_part(), {&boundaryPart}); |
| 237 |
|
| 238 |
sharedSide = bulkPtr->get_entity(meta.side_rank(), 100983); |
| 239 |
EXPECT_TRUE(bulkPtr->bucket(sharedSide).member(boundaryPart)); |
| 240 |
|
| 241 |
EXPECT_TRUE(stk::mesh::check_interior_block_boundary_sides(*bulkPtr, meta.universal_part(), boundaryPart)); |
| 242 |
} |
| 243 |
|
| 244 |
class TestSideSet : public stk::unit_test_util::MeshFixture |
| 245 |
{ |
| 246 |
protected: |
| 247 |
void setup_2_block_mesh() |
| 248 |
{ |
| 249 |
allocate_bulk(stk::mesh::BulkData::NO_AUTO_AURA); |
| 250 |
stk::mesh::MetaData& meta = get_meta(); |
| 251 |
stk::mesh::Part& block2 = meta.declare_part_with_topology("block_2", stk::topology::HEX_8); |
| 252 |
stk::mesh::Part& surface1 = meta.declare_part_with_topology("surface_1", stk::topology::QUAD_4); |
| 253 |
stk::io::put_io_part_attribute(block2); |
| 254 |
stk::io::put_io_part_attribute(surface1); |
| 255 |
meta.set_part_id(block2, 2); |
| 256 |
meta.set_part_id(surface1, 1); |
| 257 |
|
| 258 |
stk::io::fill_mesh("generated:2x2x2", get_bulk()); |
| 259 |
|
| 260 |
move_elems_from_block_to_block(get_bulk(), {2, 4, 6, 8}, "block_1", "block_2"); |
| 261 |
} |
| 262 |
}; |
| 263 |
|
| 264 |
TEST_F(TestSideSet, creatingSideOfOneElem_eachProcHasOneSide) |
| 265 |
{ |
| 266 |
setup_mesh("generated:1x1x4", stk::mesh::BulkData::NO_AUTO_AURA); |
| 267 |
|
| 268 |
stk::mesh::EntityVector localElems; |
| 269 |
stk::mesh::get_selected_entities(get_meta().locally_owned_part(), get_bulk().buckets(stk::topology::ELEM_RANK), localElems); |
| 270 |
ASSERT_GE(localElems.size(), 1u); |
| 271 |
|
| 272 |
stk::mesh::SideSet sideSet(get_bulk()); |
| 273 |
sideSet.add(stk::mesh::SideSetEntry(localElems[0], 1)); |
| 274 |
|
| 275 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().locally_owned_part(), get_bulk().buckets(get_meta().side_rank()))); |
| 276 |
get_bulk().create_side_entities(sideSet, {}); |
| 277 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().locally_owned_part(), get_bulk().buckets(get_meta().side_rank()))); |
| 278 |
} |
| 279 |
|
| 280 |
TEST_F(TestSideSet, createSideSetsSpanningMultipleBlocks) |
| 281 |
{ |
| 282 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) < 3) { |
| 283 |
const std::string filename = "sideSetMesh.g"; |
| 284 |
create_two_elem_block_mesh_with_spanning_sidesets(filename); |
| 285 |
|
| 286 |
allocate_bulk(stk::mesh::BulkData::NO_AUTO_AURA); |
| 287 |
|
| 288 |
load_mesh_with_specified_splitting(*bulkData, filename, Ioss::SPLIT_BY_ELEMENT_BLOCK); |
| 289 |
|
| 290 |
stk::mesh::create_bulkdata_sidesets(get_bulk()); |
| 291 |
|
| 292 |
EXPECT_EQ(2u, get_bulk().get_number_of_sidesets()); |
| 293 |
stk::unit_test_util::delete_mesh(filename); |
| 294 |
} |
| 295 |
} |
| 296 |
|
| 297 |
|
| 298 |
TEST_F(TestSideSet, createSingleSidedSideSetOnBlock1BetweenBlocks) |
| 299 |
{ |
| 300 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) { |
| 301 |
setup_2_block_mesh(); |
| 302 |
|
| 303 |
create_sideset(get_bulk(), "surface_1", "block_1"); |
| 304 |
create_sides_between_blocks(get_bulk(), "block_1", "block_2", "surface_1"); |
| 305 |
|
| 306 |
check_sideset_elems(get_bulk(), "surface_1", {1, 3, 5, 7}); |
| 307 |
} |
| 308 |
} |
| 309 |
|
| 310 |
TEST_F(TestSideSet, createSingleSidedSideSetOnBlock1BetweenBlocks_ChangeSideParts) |
| 311 |
{ |
| 312 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) { |
| 313 |
setup_2_block_mesh(); |
| 314 |
|
| 315 |
create_sideset(get_bulk(), "surface_1", "block_1"); |
| 316 |
stk::mesh::create_all_sides(get_bulk(), get_meta().universal_part(), stk::mesh::PartVector{}, false); |
| 317 |
move_sides_between_blocks_into_sideset_part(get_bulk(), "block_1", "block_2", "surface_1"); |
| 318 |
|
| 319 |
check_sideset_elems(get_bulk(), "surface_1", {1, 3, 5, 7}); |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
TEST_F(TestSideSet, createSingleSidedSideSetOnBlock2BetweenBlocks) |
| 324 |
{ |
| 325 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) { |
| 326 |
setup_2_block_mesh(); |
| 327 |
|
| 328 |
create_sideset(get_bulk(), "surface_1", "block_2"); |
| 329 |
create_sides_between_blocks(get_bulk(), "block_1", "block_2", "surface_1"); |
| 330 |
|
| 331 |
check_sideset_elems(get_bulk(), "surface_1", {2, 4, 6, 8}); |
| 332 |
} |
| 333 |
} |
| 334 |
|
| 335 |
TEST_F(TestSideSet, createSingleSidedSideSetOnBlock2BetweenBlocks_ChangeSideParts) |
| 336 |
{ |
| 337 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) { |
| 338 |
setup_2_block_mesh(); |
| 339 |
|
| 340 |
create_sideset(get_bulk(), "surface_1", "block_2"); |
| 341 |
stk::mesh::create_all_sides(get_bulk(), get_meta().universal_part(), stk::mesh::PartVector{}, false); |
| 342 |
move_sides_between_blocks_into_sideset_part(get_bulk(), "block_1", "block_2", "surface_1"); |
| 343 |
|
| 344 |
check_sideset_elems(get_bulk(), "surface_1", {2, 4, 6, 8}); |
| 345 |
} |
| 346 |
} |
| 347 |
|
| 348 |
TEST_F(TestSideSet, createSingleSidedSideSetOnBlock1BetweenBlocks_WithSubsetSurfaceTouchingBlock1AndSurface1TouchingBothBlocks) |
| 349 |
{ |
| 350 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) { |
| 351 |
|
| 352 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 353 |
stk::mesh::MetaData& meta = get_meta(); |
| 354 |
stk::mesh::Part& block1 = meta.declare_part_with_topology("block_1", stk::topology::HEX_8); |
| 355 |
stk::mesh::Part& block2 = meta.declare_part_with_topology("block_2", stk::topology::HEX_8); |
| 356 |
stk::mesh::Part& surface1 = meta.declare_part_with_topology("surface_1", stk::topology::QUAD_4); |
| 357 |
stk::mesh::Part& surface1TouchingBlock1 = meta.declare_part_with_topology("surface_1_touching_block1", stk::topology::QUAD_4); |
| 358 |
meta.declare_part_subset(surface1, surface1TouchingBlock1); |
| 359 |
|
| 360 |
stk::io::put_io_part_attribute(block2); |
| 361 |
stk::io::put_io_part_attribute(surface1); |
| 362 |
stk::io::put_io_part_attribute(surface1TouchingBlock1); |
| 363 |
|
| 364 |
meta.set_surface_to_block_mapping(&surface1, stk::mesh::ConstPartVector{&block1, &block2}); |
| 365 |
|
| 366 |
meta.set_part_id(block2, 2); |
| 367 |
meta.set_part_id(surface1, 1); |
| 368 |
meta.set_part_id(surface1TouchingBlock1, 1); |
| 369 |
|
| 370 |
stk::io::fill_mesh("generated:2x1x1", get_bulk()); |
| 371 |
|
| 372 |
move_elems_from_block_to_block(get_bulk(), {2}, "block_1", "block_2"); |
| 373 |
|
| 374 |
create_sideset(get_bulk(), surface1TouchingBlock1.name(), "block_1"); |
| 375 |
stk::mesh::create_all_sides(get_bulk(), get_meta().universal_part(), stk::mesh::PartVector{}, false); |
| 376 |
move_sides_between_blocks_into_sideset_part(get_bulk(), "block_1", "block_2", surface1TouchingBlock1.name()); |
| 377 |
|
| 378 |
check_sideset_elems(get_bulk(), "surface_1", {1}); |
| 379 |
} |
| 380 |
} |
| 381 |
|
| 382 |
TEST_F(TestSideSet, findSidesetEntry) |
| 383 |
{ |
| 384 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 385 |
{ |
| 386 |
setup_mesh("generated:1x1x1|sideset:x", stk::mesh::BulkData::NO_AUTO_AURA); |
| 387 |
stk::mesh::Part* sidePart = get_meta().get_part("surface_1"); |
| 388 |
|
| 389 |
stk::mesh::SideSet& sideset = get_bulk().get_sideset(*sidePart); |
| 390 |
stk::mesh::Entity elem1 = get_bulk().get_entity(stk::topology::ELEM_RANK, 1); |
| 391 |
const stk::mesh::ConnectivityOrdinal expectedSideOrdinal = 3; |
| 392 |
const int numSides = 6; |
| 393 |
for (int i = 0; i < numSides; ++i) |
| 394 |
{ |
| 395 |
if (expectedSideOrdinal != stk::mesh::ConnectivityOrdinal(i)) |
| 396 |
{ |
| 397 |
EXPECT_FALSE(sideset.contains(elem1, stk::mesh::ConnectivityOrdinal(i))); |
| 398 |
EXPECT_FALSE(sideset.contains(stk::mesh::SideSetEntry(elem1, stk::mesh::ConnectivityOrdinal(i)))); |
| 399 |
} |
| 400 |
else |
| 401 |
{ |
| 402 |
EXPECT_TRUE(sideset.contains(elem1, stk::mesh::ConnectivityOrdinal(i))); |
| 403 |
EXPECT_TRUE(sideset.contains(stk::mesh::SideSetEntry(elem1, stk::mesh::ConnectivityOrdinal(i)))); |
| 404 |
} |
| 405 |
} |
| 406 |
} |
| 407 |
} |
| 408 |
|
| 409 |
|
| 410 |
namespace { |
| 411 |
void create_sideset_observer(stk::mesh::BulkData& bulk, stk::mesh::Selector activeSelector = stk::mesh::Selector()) |
| 412 |
{ |
| 413 |
if (!bulk.has_observer_type<stk::mesh::SidesetUpdater>()) { |
| 414 |
if (activeSelector == stk::mesh::Selector()) { |
| 415 |
activeSelector = bulk.mesh_meta_data().universal_part(); |
| 416 |
} |
| 417 |
bulk.register_observer(std::make_shared<stk::mesh::IncrementalSidesetUpdater>(bulk, activeSelector)); |
| 418 |
} |
| 419 |
} |
| 420 |
} |
| 421 |
|
| 422 |
class SideSetModification : public stk::unit_test_util::MeshFixture |
| 423 |
{ |
| 424 |
protected: |
| 425 |
stk::mesh::Entity create_hex_solo_side(const stk::mesh::PartVector& parts) |
| 426 |
{ |
| 427 |
stk::mesh::PartVector quadParts = parts; |
| 428 |
stk::mesh::Part& quadTopoPart = get_bulk().mesh_meta_data().get_topology_root_part(stk::topology::QUAD_4); |
| 429 |
quadParts.push_back(&quadTopoPart); |
| 430 |
stk::mesh::Entity soloSide = get_bulk().declare_solo_side(quadParts); |
| 431 |
|
| 432 |
return soloSide; |
| 433 |
} |
| 434 |
|
| 435 |
stk::mesh::Entity create_hex_solo_side(unsigned nodeOffset, const stk::mesh::PartVector& parts) |
| 436 |
{ |
| 437 |
stk::mesh::Part& nodePart = get_bulk().mesh_meta_data().get_topology_root_part(stk::topology::NODE); |
| 438 |
stk::mesh::PartVector nodeParts = {&nodePart}; |
| 439 |
|
| 440 |
stk::mesh::PartVector quadParts = parts; |
| 441 |
stk::mesh::Part& quadTopoPart = get_bulk().mesh_meta_data().get_topology_root_part(stk::topology::QUAD_4); |
| 442 |
quadParts.push_back(&quadTopoPart); |
| 443 |
stk::mesh::Entity soloSide = get_bulk().declare_solo_side(quadParts); |
| 444 |
|
| 445 |
stk::mesh::Permutation perm = stk::mesh::Permutation::INVALID_PERMUTATION; |
| 446 |
stk::mesh::OrdinalVector scratch1, scratch2, scratch3; |
| 447 |
|
| 448 |
for(unsigned j = 0; j < 4; ++j) |
| 449 |
{ |
| 450 |
unsigned id = nodeOffset + j; |
| 451 |
stk::mesh::Entity node = get_bulk().get_entity(stk::topology::NODE_RANK, id); |
| 452 |
if (!get_bulk().is_valid(node)) { |
| 453 |
node = get_bulk().declare_node(id, nodeParts); |
| 454 |
} |
| 455 |
get_bulk().declare_relation(soloSide, node, j, perm, scratch1, scratch2, scratch3); |
| 456 |
} |
| 457 |
|
| 458 |
return soloSide; |
| 459 |
} |
| 460 |
|
| 461 |
void snap_hex_solo_side_to_element(stk::mesh::Entity elem, stk::mesh::ConnectivityOrdinal ordinal, stk::mesh::Entity side) |
| 462 |
{ |
| 463 |
stk::mesh::MetaData& meta = get_bulk().mesh_meta_data(); |
| 464 |
ASSERT_EQ(stk::topology::ELEM_RANK, get_bulk().entity_rank(elem)); |
| 465 |
ASSERT_EQ(meta.side_rank(), get_bulk().entity_rank(side)); |
| 466 |
|
| 467 |
stk::mesh::EntityVector sideNodes; |
| 468 |
stk::mesh::impl::fill_element_side_nodes_from_topology(get_bulk().bucket(elem).topology(), get_bulk().begin_nodes(elem), ordinal, sideNodes); |
| 469 |
|
| 470 |
stk::mesh::Permutation perm = stk::mesh::Permutation::INVALID_PERMUTATION; |
| 471 |
stk::mesh::OrdinalVector scratch1, scratch2, scratch3; |
| 472 |
|
| 473 |
for(unsigned j = 0; j < sideNodes.size(); ++j) { |
| 474 |
get_bulk().declare_relation(side, sideNodes[j], j, perm, scratch1, scratch2, scratch3); |
| 475 |
} |
| 476 |
|
| 477 |
get_bulk().declare_relation(elem, side, ordinal); |
| 478 |
} |
| 479 |
|
| 480 |
void setup_test(const std::string& meshSpec) |
| 481 |
{ |
| 482 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 483 |
m_soloPart = &get_meta().declare_part("soloPart", get_meta().side_rank()); |
| 484 |
|
| 485 |
stk::io::fill_mesh(meshSpec, get_bulk()); |
| 486 |
create_sideset_observer(get_bulk()); |
| 487 |
m_sidePart = get_meta().get_part("surface_1"); |
| 488 |
|
| 489 |
if(m_sidePart == nullptr) { |
| 490 |
m_sidePart = &get_meta().declare_part_with_topology("sidesetPart", stk::topology::QUAD_4); |
| 491 |
get_meta().set_part_id(*m_sidePart, 100u); |
| 492 |
|
| 493 |
stk::mesh::Part* block_1 = get_meta().get_part("block_1"); |
| 494 |
ASSERT_TRUE(block_1 != nullptr); |
| 495 |
get_meta().set_surface_to_block_mapping(m_sidePart, stk::mesh::ConstPartVector{block_1}); |
| 496 |
} |
| 497 |
|
| 498 |
m_sideset = &get_bulk().create_sideset(*m_sidePart); |
| 499 |
m_elem1 = get_bulk().get_entity(stk::topology::ELEM_RANK, 1); |
| 500 |
ASSERT_TRUE(get_bulk().is_valid(m_elem1)); |
| 501 |
|
| 502 |
stk::mesh::EntityVector faces; |
| 503 |
stk::mesh::get_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK), faces); |
| 504 |
|
| 505 |
for(stk::mesh::Entity face : faces) { |
| 506 |
ASSERT_TRUE(get_bulk().is_valid(face)); |
| 507 |
ASSERT_TRUE(get_bulk().bucket(face).member(*m_sidePart)); |
| 508 |
} |
| 509 |
} |
| 510 |
|
| 511 |
void create_declared_element_side(stk::mesh::EntityId elemId, stk::mesh::ConnectivityOrdinal ordinal, const stk::mesh::PartVector& addParts) |
| 512 |
{ |
| 513 |
stk::mesh::Entity elem = get_bulk().get_entity(stk::topology::ELEM_RANK, elemId); |
| 514 |
ASSERT_TRUE(get_bulk().is_valid(elem)); |
| 515 |
|
| 516 |
const stk::mesh::ConnectivityOrdinal* ordinals = get_bulk().begin_ordinals(elem, stk::topology::FACE_RANK); |
| 517 |
for(unsigned i=0; i<get_bulk().num_connectivity(elem, stk::topology::FACE_RANK); i++) { |
| 518 |
ASSERT_TRUE(ordinals[i] != ordinal); |
| 519 |
} |
| 520 |
|
| 521 |
get_bulk().modification_begin(); |
| 522 |
m_declaredSideNotInSideset = get_bulk().declare_element_side(elem, ordinal, addParts); |
| 523 |
get_bulk().modification_end(); |
| 524 |
} |
| 525 |
|
| 526 |
void setup_test_with_declared_element_side(const std::string& meshSpec, stk::mesh::EntityId elemId, stk::mesh::ConnectivityOrdinal ordinal) |
| 527 |
{ |
| 528 |
setup_test(meshSpec); |
| 529 |
|
| 530 |
stk::mesh::PartVector addParts; |
| 531 |
create_declared_element_side(elemId, ordinal, addParts); |
| 532 |
|
| 533 |
ASSERT_TRUE(get_bulk().is_valid(m_declaredSideNotInSideset)); |
| 534 |
ASSERT_FALSE(get_bulk().bucket(m_declaredSideNotInSideset).member(*m_sidePart)); |
| 535 |
} |
| 536 |
|
| 537 |
void setup_test_with_declared_element_side_in_solo_part(const std::string& meshSpec, stk::mesh::EntityId elemId, stk::mesh::ConnectivityOrdinal ordinal) |
| 538 |
{ |
| 539 |
setup_test(meshSpec); |
| 540 |
|
| 541 |
stk::mesh::PartVector addParts; |
| 542 |
addParts.push_back(m_soloPart); |
| 543 |
create_declared_element_side(elemId, ordinal, addParts); |
| 544 |
|
| 545 |
ASSERT_TRUE(get_bulk().is_valid(m_declaredSideNotInSideset)); |
| 546 |
ASSERT_FALSE(get_bulk().bucket(m_declaredSideNotInSideset).member(*m_sidePart)); |
| 547 |
ASSERT_TRUE(get_bulk().bucket(m_declaredSideNotInSideset).member(*m_soloPart)); |
| 548 |
ASSERT_FALSE(get_bulk().does_sideset_exist(*m_soloPart)); |
| 549 |
} |
| 550 |
|
| 551 |
void create_solo_side_no_mesh_modification(bool insertIntoSoloPart) |
| 552 |
{ |
| 553 |
unsigned numNodes = stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::NODE_RANK)); |
| 554 |
|
| 555 |
unsigned nodeOffset = numNodes + 1; |
| 556 |
|
| 557 |
stk::mesh::PartVector addParts; |
| 558 |
if(insertIntoSoloPart) { |
| 559 |
addParts.push_back(m_soloPart); |
| 560 |
} |
| 561 |
|
| 562 |
m_soloSide = create_hex_solo_side(nodeOffset, addParts); |
| 563 |
} |
| 564 |
|
| 565 |
void create_solo_side(bool insertIntoSoloPart) |
| 566 |
{ |
| 567 |
get_bulk().modification_begin(); |
| 568 |
create_solo_side_no_mesh_modification(insertIntoSoloPart); |
| 569 |
get_bulk().modification_end(); |
| 570 |
} |
| 571 |
|
| 572 |
void verify_test_with_solo_side(bool isSoloSideInSoloPart) |
| 573 |
{ |
| 574 |
ASSERT_TRUE(get_bulk().is_valid(m_soloSide)); |
| 575 |
ASSERT_FALSE(get_bulk().does_sideset_exist(*m_soloPart)); |
| 576 |
ASSERT_FALSE(get_bulk().bucket(m_soloSide).member(*m_sidePart)); |
| 577 |
ASSERT_EQ(isSoloSideInSoloPart, get_bulk().bucket(m_soloSide).member(*m_soloPart)); |
| 578 |
} |
| 579 |
|
| 580 |
void setup_test_with_solo_side(const std::string& meshSpec) |
| 581 |
{ |
| 582 |
bool isSoloSideInSoloPart = false; |
| 583 |
setup_test(meshSpec); |
| 584 |
create_solo_side(isSoloSideInSoloPart); |
| 585 |
verify_test_with_solo_side(isSoloSideInSoloPart); |
| 586 |
} |
| 587 |
|
| 588 |
void setup_test_with_solo_side_in_solo_part(const std::string& meshSpec) |
| 589 |
{ |
| 590 |
bool isSoloSideInSoloPart = true; |
| 591 |
setup_test(meshSpec); |
| 592 |
create_solo_side(isSoloSideInSoloPart); |
| 593 |
verify_test_with_solo_side(isSoloSideInSoloPart); |
| 594 |
} |
| 595 |
|
| 596 |
stk::mesh::Part* m_sidePart = nullptr; |
| 597 |
stk::mesh::SideSet* m_sideset = nullptr; |
| 598 |
stk::mesh::Entity m_soloSide; |
| 599 |
stk::mesh::Part* m_soloPart = nullptr; |
| 600 |
stk::mesh::Entity m_declaredSideNotInSideset; |
| 601 |
stk::mesh::Entity m_elem1; |
| 602 |
}; |
| 603 |
|
| 604 |
TEST_F(SideSetModification, removeSidesetEntry_AfterDestroyElement) |
| 605 |
{ |
| 606 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 607 |
{ |
| 608 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 609 |
setup_test("generated:1x1x1|sideset:x"); |
| 610 |
EXPECT_EQ(1u, m_sideset->size()); |
| 611 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 612 |
|
| 613 |
get_bulk().modification_begin(); |
| 614 |
get_bulk().destroy_entity(m_elem1); |
| 615 |
get_bulk().modification_end(); |
| 616 |
|
| 617 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 618 |
EXPECT_EQ(0u, m_sideset->size()); |
| 619 |
} |
| 620 |
} |
| 621 |
|
| 622 |
TEST_F(SideSetModification, keepSidesetEntry_AfterDestroyElementNotConnectedToSideset) |
| 623 |
{ |
| 624 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 625 |
{ |
| 626 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 627 |
setup_test("generated:2x1x1|sideset:x"); |
| 628 |
EXPECT_EQ(1u, m_sideset->size()); |
| 629 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 630 |
|
| 631 |
stk::mesh::Entity elem2 = get_bulk().get_entity(stk::topology::ELEM_RANK, 2); |
| 632 |
ASSERT_TRUE(get_bulk().is_valid(elem2)); |
| 633 |
get_bulk().modification_begin(); |
| 634 |
get_bulk().destroy_entity(elem2); |
| 635 |
get_bulk().modification_end(); |
| 636 |
|
| 637 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 638 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::ELEM_RANK))); |
| 639 |
EXPECT_EQ(1u, m_sideset->size()); |
| 640 |
} |
| 641 |
} |
| 642 |
|
| 643 |
TEST_F(SideSetModification, removeSidesetEntry_AfterDestroyFace) |
| 644 |
{ |
| 645 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 646 |
{ |
| 647 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 648 |
setup_test("generated:1x1x1|sideset:x"); |
| 649 |
EXPECT_EQ(1u, m_sideset->size()); |
| 650 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 651 |
|
| 652 |
stk::mesh::EntityVector faces; |
| 653 |
stk::mesh::get_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK), faces); |
| 654 |
get_bulk().modification_begin(); |
| 655 |
bool destroyFaceWithUpwardRelationToElement = get_bulk().destroy_entity(faces[0]); |
| 656 |
EXPECT_FALSE(destroyFaceWithUpwardRelationToElement); |
| 657 |
get_bulk().modification_end(); |
| 658 |
|
| 659 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 660 |
EXPECT_EQ(1u, m_sideset->size()); |
| 661 |
} |
| 662 |
} |
| 663 |
|
| 664 |
TEST_F(SideSetModification, removeSidesetEntry_AfterFaceChangePart) |
| 665 |
{ |
| 666 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 667 |
{ |
| 668 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 669 |
setup_test("generated:1x1x1|sideset:x"); |
| 670 |
EXPECT_EQ(1u, m_sideset->size()); |
| 671 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 672 |
|
| 673 |
stk::mesh::EntityVector faces; |
| 674 |
stk::mesh::get_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK), faces); |
| 675 |
get_bulk().modification_begin(); |
| 676 |
get_bulk().change_entity_parts(faces[0], stk::mesh::PartVector{}, stk::mesh::PartVector{m_sidePart}); |
| 677 |
get_bulk().modification_end(); |
| 678 |
|
| 679 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 680 |
EXPECT_EQ(0u, m_sideset->size()); |
| 681 |
ASSERT_FALSE(get_bulk().bucket(faces[0]).member(*m_sidePart)); |
| 682 |
} |
| 683 |
} |
| 684 |
|
| 685 |
TEST_F(SideSetModification, removeSidesetEntry_AfterDestroyRelationFromElementToFace) |
| 686 |
{ |
| 687 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 688 |
{ |
| 689 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 690 |
setup_test("generated:1x1x1|sideset:x"); |
| 691 |
EXPECT_EQ(1u, m_sideset->size()); |
| 692 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 693 |
|
| 694 |
stk::mesh::EntityVector faces; |
| 695 |
stk::mesh::get_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK), faces); |
| 696 |
get_bulk().modification_begin(); |
| 697 |
stk::mesh::ConnectivityOrdinal ordinal = 3; |
| 698 |
EXPECT_TRUE(get_bulk().destroy_relation(m_elem1, faces[0], ordinal)); |
| 699 |
EXPECT_TRUE(get_bulk().destroy_entity(faces[0])); |
| 700 |
get_bulk().modification_end(); |
| 701 |
|
| 702 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 703 |
EXPECT_EQ(0u, m_sideset->size()); |
| 704 |
} |
| 705 |
} |
| 706 |
|
| 707 |
TEST_F(SideSetModification, removeSidesetEntry_AfterFaceChangePartAndThenDestroyRelationFromElementToFace) |
| 708 |
{ |
| 709 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 710 |
{ |
| 711 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 712 |
setup_test("generated:1x1x1|sideset:x"); |
| 713 |
EXPECT_EQ(1u, m_sideset->size()); |
| 714 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 715 |
|
| 716 |
stk::mesh::EntityVector faces; |
| 717 |
stk::mesh::get_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK), faces); |
| 718 |
get_bulk().modification_begin(); |
| 719 |
get_bulk().change_entity_parts(faces[0], stk::mesh::PartVector{}, stk::mesh::PartVector{m_sidePart}); |
| 720 |
stk::mesh::ConnectivityOrdinal ordinal = 3; |
| 721 |
EXPECT_TRUE(get_bulk().destroy_relation(m_elem1, faces[0], ordinal)); |
| 722 |
get_bulk().modification_end(); |
| 723 |
|
| 724 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 725 |
EXPECT_EQ(0u, m_sideset->size()); |
| 726 |
} |
| 727 |
} |
| 728 |
|
| 729 |
TEST_F(SideSetModification, removeSidesetEntry_AfterDestroyRelationFromElementToFaceAndThenFaceChangePart) |
| 730 |
{ |
| 731 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 732 |
{ |
| 733 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 734 |
setup_test("generated:1x1x1|sideset:x"); |
| 735 |
EXPECT_EQ(1u, m_sideset->size()); |
| 736 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 737 |
|
| 738 |
stk::mesh::EntityVector faces; |
| 739 |
stk::mesh::get_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK), faces); |
| 740 |
get_bulk().modification_begin(); |
| 741 |
stk::mesh::ConnectivityOrdinal ordinal = 3; |
| 742 |
EXPECT_TRUE(get_bulk().destroy_relation(m_elem1, faces[0], ordinal)); |
| 743 |
get_bulk().change_entity_parts(faces[0], stk::mesh::PartVector{}, stk::mesh::PartVector{m_sidePart}); |
| 744 |
get_bulk().modification_end(); |
| 745 |
|
| 746 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 747 |
EXPECT_EQ(0u, m_sideset->size()); |
| 748 |
} |
| 749 |
} |
| 750 |
|
| 751 |
TEST_F(SideSetModification, keepSidesetEntry_AfterDestroyFaceNotInSideset) |
| 752 |
{ |
| 753 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 754 |
{ |
| 755 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 756 |
setup_test_with_solo_side("generated:1x1x1|sideset:x"); |
| 757 |
EXPECT_EQ(1u, m_sideset->size()); |
| 758 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 759 |
|
| 760 |
get_bulk().modification_begin(); |
| 761 |
get_bulk().destroy_entity(m_soloSide); |
| 762 |
get_bulk().modification_end(); |
| 763 |
|
| 764 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 765 |
EXPECT_EQ(1u, m_sideset->size()); |
| 766 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 767 |
} |
| 768 |
} |
| 769 |
|
| 770 |
TEST_F(SideSetModification, keepSidesetEntry_AfterFaceChangePartNotInSideset) |
| 771 |
{ |
| 772 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 773 |
{ |
| 774 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 775 |
setup_test_with_solo_side_in_solo_part("generated:1x1x1|sideset:x"); |
| 776 |
EXPECT_EQ(1u, m_sideset->size()); |
| 777 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 778 |
|
| 779 |
get_bulk().modification_begin(); |
| 780 |
get_bulk().change_entity_parts(m_soloSide, stk::mesh::PartVector{}, stk::mesh::PartVector{m_soloPart}); |
| 781 |
get_bulk().modification_end(); |
| 782 |
|
| 783 |
EXPECT_EQ(2u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 784 |
EXPECT_EQ(1u, m_sideset->size()); |
| 785 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 786 |
} |
| 787 |
} |
| 788 |
|
| 789 |
TEST_F(SideSetModification, keepSidesetEntry_AfterDestroyRelationFromElementToFaceNotInSideset) |
| 790 |
{ |
| 791 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 792 |
{ |
| 793 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 794 |
stk::mesh::ConnectivityOrdinal ordinal = 5; |
| 795 |
stk::mesh::EntityId elemId = 1u; |
| 796 |
setup_test_with_declared_element_side("generated:1x1x1|sideset:x", elemId, ordinal); |
| 797 |
EXPECT_EQ(1u, m_sideset->size()); |
| 798 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 799 |
|
| 800 |
get_bulk().modification_begin(); |
| 801 |
EXPECT_TRUE(get_bulk().destroy_relation(m_elem1, m_declaredSideNotInSideset, ordinal)); |
| 802 |
get_bulk().modification_end(); |
| 803 |
|
| 804 |
EXPECT_EQ(2u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 805 |
EXPECT_EQ(1u, m_sideset->size()); |
| 806 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 807 |
} |
| 808 |
} |
| 809 |
|
| 810 |
TEST_F(SideSetModification, keepSidesetEntry_AfterFaceChangePartAndThenDestroyRelationFromElementToFaceNotInSideset) |
| 811 |
{ |
| 812 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 813 |
{ |
| 814 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 815 |
stk::mesh::ConnectivityOrdinal ordinal = 5; |
| 816 |
stk::mesh::EntityId elemId = 1u; |
| 817 |
setup_test_with_declared_element_side_in_solo_part("generated:1x1x1|sideset:x", elemId, ordinal); |
| 818 |
EXPECT_EQ(1u, m_sideset->size()); |
| 819 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 820 |
|
| 821 |
get_bulk().modification_begin(); |
| 822 |
get_bulk().change_entity_parts(m_declaredSideNotInSideset, stk::mesh::PartVector{}, stk::mesh::PartVector{m_soloPart}); |
| 823 |
EXPECT_TRUE(get_bulk().destroy_relation(m_elem1, m_declaredSideNotInSideset, ordinal)); |
| 824 |
get_bulk().modification_end(); |
| 825 |
|
| 826 |
EXPECT_EQ(2u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 827 |
EXPECT_EQ(1u, m_sideset->size()); |
| 828 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 829 |
} |
| 830 |
} |
| 831 |
|
| 832 |
TEST_F(SideSetModification, keepSidesetEntry_AfterDestroyRelationFromElementToFaceAndThenFaceChangePartNotInSideset) |
| 833 |
{ |
| 834 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 835 |
{ |
| 836 |
stk::mesh::ConnectivityOrdinal inputSidesetOrdinal = 3; |
| 837 |
stk::mesh::ConnectivityOrdinal ordinal = 5; |
| 838 |
stk::mesh::EntityId elemId = 1u; |
| 839 |
setup_test_with_declared_element_side_in_solo_part("generated:1x1x1|sideset:x", elemId, ordinal); |
| 840 |
EXPECT_EQ(1u, m_sideset->size()); |
| 841 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 842 |
|
| 843 |
get_bulk().modification_begin(); |
| 844 |
EXPECT_TRUE(get_bulk().destroy_relation(m_elem1, m_declaredSideNotInSideset, ordinal)); |
| 845 |
get_bulk().change_entity_parts(m_declaredSideNotInSideset, stk::mesh::PartVector{}, stk::mesh::PartVector{m_soloPart}); |
| 846 |
get_bulk().modification_end(); |
| 847 |
|
| 848 |
EXPECT_EQ(2u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 849 |
EXPECT_EQ(1u, m_sideset->size()); |
| 850 |
EXPECT_TRUE(m_sideset->contains(m_elem1, inputSidesetOrdinal)); |
| 851 |
} |
| 852 |
} |
| 853 |
|
| 854 |
TEST_F(SideSetModification, addSidesetEntry_AfterCreateFaceInSideset) |
| 855 |
{ |
| 856 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 857 |
{ |
| 858 |
setup_test("generated:1x1x1"); |
| 859 |
EXPECT_EQ(0u, m_sideset->size()); |
| 860 |
|
| 861 |
get_bulk().modification_begin(); |
| 862 |
stk::mesh::ConnectivityOrdinal ordinal = 3; |
| 863 |
stk::mesh::Entity sidesetSide = get_bulk().declare_element_side(m_elem1, ordinal, stk::mesh::PartVector{m_sidePart}); |
| 864 |
get_bulk().modification_end(); |
| 865 |
|
| 866 |
EXPECT_TRUE(get_bulk().is_valid(sidesetSide)); |
| 867 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 868 |
EXPECT_EQ(1u, m_sideset->size()); |
| 869 |
EXPECT_TRUE(m_sideset->contains(m_elem1, ordinal)); |
| 870 |
} |
| 871 |
} |
| 872 |
|
| 873 |
TEST_F(SideSetModification, noAddedSidesetEntry_AfterFaceChangePartWithoutDeclareElementToFaceRelation) |
| 874 |
{ |
| 875 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 876 |
{ |
| 877 |
setup_test_with_solo_side("generated:1x1x1"); |
| 878 |
EXPECT_EQ(0u, m_sideset->size()); |
| 879 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 880 |
|
| 881 |
get_bulk().modification_begin(); |
| 882 |
get_bulk().change_entity_parts(m_soloSide, stk::mesh::PartVector{m_sidePart}, stk::mesh::PartVector{}); |
| 883 |
get_bulk().modification_end(); |
| 884 |
|
| 885 |
EXPECT_EQ(0u, m_sideset->size()); |
| 886 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 887 |
} |
| 888 |
} |
| 889 |
|
| 890 |
|
| 891 |
TEST_F(SideSetModification, noAddedSidesetEntry_AfterDeclareElementToFaceRelationWithoutFaceChangePart) |
| 892 |
{ |
| 893 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 894 |
{ |
| 895 |
setup_test("generated:1x1x1"); |
| 896 |
EXPECT_EQ(0u, m_sideset->size()); |
| 897 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 898 |
|
| 899 |
get_bulk().modification_begin(); |
| 900 |
stk::mesh::ConnectivityOrdinal ordinal = 3; |
| 901 |
stk::mesh::Entity side = get_bulk().declare_element_side(m_elem1, ordinal, stk::mesh::PartVector{}); |
| 902 |
get_bulk().modification_end(); |
| 903 |
|
| 904 |
EXPECT_TRUE(get_bulk().is_valid(side)); |
| 905 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 906 |
EXPECT_EQ(0u, m_sideset->size()); |
| 907 |
} |
| 908 |
} |
| 909 |
|
| 910 |
TEST_F(SideSetModification, addSidesetEntry_AfterDeclareElementToFaceRelationAndThenFaceChangePart) |
| 911 |
{ |
| 912 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 913 |
{ |
| 914 |
setup_test("generated:1x1x1"); |
| 915 |
EXPECT_EQ(0u, m_sideset->size()); |
| 916 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 917 |
|
| 918 |
get_bulk().modification_begin(); |
| 919 |
stk::mesh::ConnectivityOrdinal ordinal = 3; |
| 920 |
stk::mesh::Entity side = get_bulk().declare_element_side(m_elem1, ordinal, stk::mesh::PartVector{}); |
| 921 |
get_bulk().change_entity_parts(side, stk::mesh::PartVector{m_sidePart}, stk::mesh::PartVector{}); |
| 922 |
get_bulk().modification_end(); |
| 923 |
|
| 924 |
EXPECT_TRUE(get_bulk().is_valid(side)); |
| 925 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 926 |
EXPECT_EQ(1u, m_sideset->size()); |
| 927 |
EXPECT_TRUE(m_sideset->contains(m_elem1, ordinal)); |
| 928 |
} |
| 929 |
} |
| 930 |
|
| 931 |
TEST_F(SideSetModification, addSidesetEntry_AfterFaceChangePartAndThenDeclareElementToFaceRelation) |
| 932 |
{ |
| 933 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 934 |
{ |
| 935 |
setup_test_with_solo_side("generated:1x1x1"); |
| 936 |
EXPECT_EQ(0u, m_sideset->size()); |
| 937 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 938 |
|
| 939 |
get_bulk().modification_begin(); |
| 940 |
get_bulk().change_entity_parts(m_soloSide, stk::mesh::PartVector{m_sidePart}, stk::mesh::PartVector{}); |
| 941 |
|
| 942 |
stk::mesh::ConnectivityOrdinal ordinal = 3; |
| 943 |
get_bulk().declare_relation(m_elem1, m_soloSide, ordinal); |
| 944 |
get_bulk().modification_end(); |
| 945 |
|
| 946 |
EXPECT_TRUE(get_bulk().is_valid(m_soloSide)); |
| 947 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 948 |
EXPECT_EQ(1u, m_sideset->size()); |
| 949 |
EXPECT_TRUE(m_sideset->contains(m_elem1, ordinal)); |
| 950 |
} |
| 951 |
} |
| 952 |
|
| 953 |
TEST_F(SideSetModification, noAddedSidesetEntry_AfterCreateFace_ForFaceNotInSideset) |
| 954 |
{ |
| 955 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 956 |
{ |
| 957 |
setup_test("generated:1x1x1"); |
| 958 |
EXPECT_EQ(0u, m_sideset->size()); |
| 959 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 960 |
|
| 961 |
get_bulk().modification_begin(); |
| 962 |
stk::mesh::ConnectivityOrdinal sidesetOrdinal = 3; |
| 963 |
get_bulk().declare_element_side(m_elem1, sidesetOrdinal, stk::mesh::PartVector{m_sidePart}); |
| 964 |
bool isInSoloPartWhichTriggersPartChange = false; |
| 965 |
create_solo_side_no_mesh_modification(isInSoloPartWhichTriggersPartChange); |
| 966 |
get_bulk().modification_end(); |
| 967 |
|
| 968 |
EXPECT_EQ(2u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 969 |
EXPECT_EQ(1u, m_sideset->size()); |
| 970 |
EXPECT_TRUE(m_sideset->contains(m_elem1, sidesetOrdinal)); |
| 971 |
} |
| 972 |
} |
| 973 |
|
| 974 |
TEST_F(SideSetModification, noAddedSidesetEntry_AfterCreateFaceWithFaceChangePart_ForFaceNotInSideset) |
| 975 |
{ |
| 976 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 977 |
{ |
| 978 |
setup_test("generated:1x1x1"); |
| 979 |
EXPECT_EQ(0u, m_sideset->size()); |
| 980 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 981 |
|
| 982 |
get_bulk().modification_begin(); |
| 983 |
stk::mesh::ConnectivityOrdinal sidesetOrdinal = 3; |
| 984 |
get_bulk().declare_element_side(m_elem1, sidesetOrdinal, stk::mesh::PartVector{m_sidePart}); |
| 985 |
bool isInSoloPartWhichTriggersPartChange = true; |
| 986 |
create_solo_side_no_mesh_modification(isInSoloPartWhichTriggersPartChange); |
| 987 |
get_bulk().modification_end(); |
| 988 |
|
| 989 |
EXPECT_EQ(2u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 990 |
EXPECT_EQ(1u, m_sideset->size()); |
| 991 |
EXPECT_TRUE(m_sideset->contains(m_elem1, sidesetOrdinal)); |
| 992 |
} |
| 993 |
} |
| 994 |
|
| 995 |
TEST_F(SideSetModification, noAddedSidesetEntry_AfterCreateFaceWithDeclareElementToFaceRelation_ForFaceNotInSideset) |
| 996 |
{ |
| 997 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 998 |
{ |
| 999 |
setup_test("generated:1x1x1"); |
| 1000 |
EXPECT_EQ(0u, m_sideset->size()); |
| 1001 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1002 |
|
| 1003 |
get_bulk().modification_begin(); |
| 1004 |
stk::mesh::ConnectivityOrdinal sidesetOrdinal = 3; |
| 1005 |
get_bulk().declare_element_side(m_elem1, sidesetOrdinal, stk::mesh::PartVector{m_sidePart}); |
| 1006 |
stk::mesh::Entity soloSide = create_hex_solo_side(stk::mesh::PartVector{}); |
| 1007 |
stk::mesh::ConnectivityOrdinal soloSideOrdinal = 5; |
| 1008 |
snap_hex_solo_side_to_element(m_elem1, soloSideOrdinal, soloSide); |
| 1009 |
get_bulk().modification_end(); |
| 1010 |
|
| 1011 |
EXPECT_EQ(2u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1012 |
EXPECT_EQ(1u, m_sideset->size()); |
| 1013 |
EXPECT_TRUE(m_sideset->contains(m_elem1, sidesetOrdinal)); |
| 1014 |
} |
| 1015 |
} |
| 1016 |
|
| 1017 |
TEST_F(SideSetModification, noAddedSidesetEntry_AfterCreateFaceWithFaceChangePartAndThenDeclareElementToFaceRelation_ForFaceNotInSideset) |
| 1018 |
{ |
| 1019 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 1020 |
{ |
| 1021 |
setup_test("generated:1x1x1"); |
| 1022 |
EXPECT_EQ(0u, m_sideset->size()); |
| 1023 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1024 |
|
| 1025 |
get_bulk().modification_begin(); |
| 1026 |
stk::mesh::ConnectivityOrdinal sidesetOrdinal = 3; |
| 1027 |
get_bulk().declare_element_side(m_elem1, sidesetOrdinal, stk::mesh::PartVector{m_sidePart}); |
| 1028 |
stk::mesh::Entity soloSide = create_hex_solo_side(stk::mesh::PartVector{m_soloPart}); |
| 1029 |
stk::mesh::ConnectivityOrdinal soloSideOrdinal = 5; |
| 1030 |
snap_hex_solo_side_to_element(m_elem1, soloSideOrdinal, soloSide); |
| 1031 |
get_bulk().modification_end(); |
| 1032 |
|
| 1033 |
EXPECT_EQ(2u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1034 |
EXPECT_EQ(1u, m_sideset->size()); |
| 1035 |
EXPECT_TRUE(m_sideset->contains(m_elem1, sidesetOrdinal)); |
| 1036 |
} |
| 1037 |
} |
| 1038 |
|
| 1039 |
TEST_F(SideSetModification, noAddedSidesetEntry_AfterCreateFaceWithDeclareElementToFaceRelationAndThenFaceChangePart_ForFaceNotInSideset) |
| 1040 |
{ |
| 1041 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 1042 |
{ |
| 1043 |
setup_test("generated:1x1x1"); |
| 1044 |
EXPECT_EQ(0u, m_sideset->size()); |
| 1045 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1046 |
|
| 1047 |
get_bulk().modification_begin(); |
| 1048 |
stk::mesh::ConnectivityOrdinal sidesetOrdinal = 3; |
| 1049 |
get_bulk().declare_element_side(m_elem1, sidesetOrdinal, stk::mesh::PartVector{m_sidePart}); |
| 1050 |
stk::mesh::Entity soloSide = create_hex_solo_side(stk::mesh::PartVector{}); |
| 1051 |
stk::mesh::ConnectivityOrdinal soloSideOrdinal = 5; |
| 1052 |
snap_hex_solo_side_to_element(m_elem1, soloSideOrdinal, soloSide); |
| 1053 |
get_bulk().change_entity_parts(soloSide, stk::mesh::PartVector{m_soloPart}, stk::mesh::PartVector{}); |
| 1054 |
get_bulk().modification_end(); |
| 1055 |
|
| 1056 |
EXPECT_EQ(2u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1057 |
EXPECT_EQ(1u, m_sideset->size()); |
| 1058 |
EXPECT_TRUE(m_sideset->contains(m_elem1, sidesetOrdinal)); |
| 1059 |
} |
| 1060 |
} |
| 1061 |
|
| 1062 |
TEST_F(SideSetModification, emptySideset_AfterRemoveOneConnectedElementFromBlock) |
| 1063 |
{ |
| 1064 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1065 |
|
| 1066 |
setup_test("generated:1x1x1"); |
| 1067 |
EXPECT_EQ(0u, m_sideset->size()); |
| 1068 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1069 |
|
| 1070 |
get_bulk().modification_begin(); |
| 1071 |
stk::mesh::ConnectivityOrdinal sidesetOrdinal = 5; |
| 1072 |
stk::mesh::Entity side = get_bulk().declare_element_side(m_elem1, sidesetOrdinal, stk::mesh::PartVector{m_sidePart}); |
| 1073 |
get_bulk().modification_end(); |
| 1074 |
|
| 1075 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1076 |
EXPECT_EQ(1u, m_sideset->size()); |
| 1077 |
EXPECT_TRUE(m_sideset->contains(m_elem1, sidesetOrdinal)); |
| 1078 |
EXPECT_EQ(1u, get_bulk().num_elements(side)); |
| 1079 |
|
| 1080 |
stk::mesh::Part* block_1 = get_meta().get_part("block_1"); |
| 1081 |
ASSERT_TRUE(block_1 != nullptr); |
| 1082 |
ASSERT_TRUE(get_bulk().bucket(side).member(*block_1)); |
| 1083 |
|
| 1084 |
get_bulk().modification_begin(); |
| 1085 |
get_bulk().change_entity_parts(m_elem1, stk::mesh::PartVector{}, stk::mesh::PartVector{block_1}); |
| 1086 |
get_bulk().modification_end(); |
| 1087 |
|
| 1088 |
EXPECT_FALSE(get_bulk().bucket(side).member(*block_1)); |
| 1089 |
EXPECT_EQ(0u, m_sideset->size()); |
| 1090 |
} |
| 1091 |
|
| 1092 |
TEST_F(SideSetModification, noChange_AfterRemoveThenAddInSameModCycleOneConnectedElementFromBlock) |
| 1093 |
{ |
| 1094 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1095 |
|
| 1096 |
setup_test("generated:1x1x1"); |
| 1097 |
EXPECT_EQ(0u, m_sideset->size()); |
| 1098 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1099 |
|
| 1100 |
get_bulk().modification_begin(); |
| 1101 |
stk::mesh::ConnectivityOrdinal sidesetOrdinal = 5; |
| 1102 |
stk::mesh::Entity side = get_bulk().declare_element_side(m_elem1, sidesetOrdinal, stk::mesh::PartVector{m_sidePart}); |
| 1103 |
get_bulk().modification_end(); |
| 1104 |
|
| 1105 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1106 |
EXPECT_EQ(1u, m_sideset->size()); |
| 1107 |
EXPECT_TRUE(m_sideset->contains(m_elem1, sidesetOrdinal)); |
| 1108 |
EXPECT_EQ(1u, get_bulk().num_elements(side)); |
| 1109 |
|
| 1110 |
stk::mesh::Part* block_1 = get_meta().get_part("block_1"); |
| 1111 |
ASSERT_TRUE(block_1 != nullptr); |
| 1112 |
ASSERT_TRUE(get_bulk().bucket(side).member(*block_1)); |
| 1113 |
|
| 1114 |
get_bulk().modification_begin(); |
| 1115 |
get_bulk().change_entity_parts(m_elem1, stk::mesh::PartVector{}, stk::mesh::PartVector{block_1}); |
| 1116 |
get_bulk().change_entity_parts(m_elem1, stk::mesh::PartVector{block_1}, stk::mesh::PartVector{}); |
| 1117 |
get_bulk().modification_end(); |
| 1118 |
|
| 1119 |
EXPECT_TRUE(get_bulk().bucket(side).member(*block_1)); |
| 1120 |
EXPECT_TRUE(get_bulk().bucket(m_elem1).member(*block_1)); |
| 1121 |
EXPECT_EQ(1u, m_sideset->size()); |
| 1122 |
EXPECT_TRUE(m_sideset->contains(m_elem1, sidesetOrdinal)); |
| 1123 |
EXPECT_EQ(1u, get_bulk().num_elements(side)); |
| 1124 |
} |
| 1125 |
|
| 1126 |
TEST_F(SideSetModification, nonEmptyInternalSideset_AfterRemoveOneConnectedElementFromBlock) |
| 1127 |
{ |
| 1128 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1129 |
|
| 1130 |
setup_test("generated:1x1x2"); |
| 1131 |
EXPECT_EQ(0u, m_sideset->size()); |
| 1132 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1133 |
|
| 1134 |
get_bulk().modification_begin(); |
| 1135 |
stk::mesh::ConnectivityOrdinal sidesetOrdinal = 5; |
| 1136 |
stk::mesh::Entity side = get_bulk().declare_element_side(m_elem1, sidesetOrdinal, stk::mesh::PartVector{m_sidePart}); |
| 1137 |
get_bulk().modification_end(); |
| 1138 |
|
| 1139 |
EXPECT_EQ(1u, stk::mesh::count_selected_entities(get_meta().universal_part(), get_bulk().buckets(stk::topology::FACE_RANK))); |
| 1140 |
EXPECT_EQ(2u, m_sideset->size()); |
| 1141 |
EXPECT_TRUE(m_sideset->contains(m_elem1, sidesetOrdinal)); |
| 1142 |
EXPECT_EQ(2u, get_bulk().num_elements(side)); |
| 1143 |
|
| 1144 |
stk::mesh::Part* block_1 = get_meta().get_part("block_1"); |
| 1145 |
ASSERT_TRUE(block_1 != nullptr); |
| 1146 |
ASSERT_TRUE(get_bulk().bucket(side).member(*block_1)); |
| 1147 |
|
| 1148 |
get_bulk().modification_begin(); |
| 1149 |
get_bulk().change_entity_parts(m_elem1, stk::mesh::PartVector{}, stk::mesh::PartVector{block_1}); |
| 1150 |
get_bulk().modification_end(); |
| 1151 |
|
| 1152 |
EXPECT_TRUE(get_bulk().bucket(side).member(*block_1)); |
| 1153 |
EXPECT_EQ(1u, m_sideset->size()); |
| 1154 |
EXPECT_EQ(2u, get_bulk().num_elements(side)); |
| 1155 |
} |
| 1156 |
|
| 1157 |
TEST(DeclareElementSide, DISABLED_textmesh_shell_tri_3_all_face_sides) |
| 1158 |
{ |
| 1159 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1160 |
|
| 1161 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1162 |
/* shell-tri-3 mesh: */ |
| 1163 |
/* 3 */ |
| 1164 |
/* * */ |
| 1165 |
/* /|\ */ |
| 1166 |
/* / | \ */ |
| 1167 |
/* 1* | *4 */ |
| 1168 |
/* \ | / */ |
| 1169 |
/* \|/ */ |
| 1170 |
/* * */ |
| 1171 |
/* 2 */ |
| 1172 |
/* */ |
| 1173 |
const std::string meshDesc = |
| 1174 |
"0,1,SHELL_TRI_3_ALL_FACE_SIDES, 1,2,3, block_1\n\ |
| 1175 |
0,2,SHELL_TRI_3_ALL_FACE_SIDES, 2,4,3, block_1"; |
| 1176 |
|
| 1177 |
std::vector<double> coords = {0,1,0, 1,0,0, 1,2,0, 2,1,0}; |
| 1178 |
|
| 1179 |
//FIXME! text-mesh doesn't recognize the all-face-sides topologies. |
| 1180 |
stk::unit_test_util::setup_text_mesh(*bulk, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 1181 |
|
| 1182 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(bulk->mesh_meta_data().universal_part(), bulk->buckets(stk::topology::FACE_RANK))); |
| 1183 |
|
| 1184 |
bulk->modification_begin(); |
| 1185 |
|
| 1186 |
stk::mesh::Entity elem1 = bulk->get_entity(stk::topology::ELEM_RANK, 1); |
| 1187 |
const unsigned sideOrdinal = 3; |
| 1188 |
stk::mesh::PartVector emptySideParts; |
| 1189 |
stk::mesh::Entity side = bulk->declare_element_side(elem1, sideOrdinal, emptySideParts); |
| 1190 |
bulk->modification_end(); |
| 1191 |
|
| 1192 |
EXPECT_EQ(stk::topology::SHELL_SIDE_BEAM_2, bulk->bucket(side).topology()); |
| 1193 |
} |
| 1194 |
|
| 1195 |
void test_shell_quad_4(stk::topology shell_topo, stk::mesh::EntityRank side_rank, |
| 1196 |
stk::topology gold_shell_side_topo, bool use_graph) |
| 1197 |
{ |
| 1198 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1199 |
/* shell-quad-4 mesh: */ |
| 1200 |
/* */ |
| 1201 |
/* */ |
| 1202 |
/* 4*-----*3----*6 */ |
| 1203 |
/* | | | */ |
| 1204 |
/* | | | */ |
| 1205 |
/* 1*-----*2----*5 */ |
| 1206 |
/* */ |
| 1207 |
|
| 1208 |
EXPECT_EQ(4u, shell_topo.num_nodes()); |
| 1209 |
|
| 1210 |
bulk->modification_begin(); |
| 1211 |
|
| 1212 |
stk::mesh::Part& shellPart = bulk->mesh_meta_data().declare_part_with_topology("shell_part", shell_topo); |
| 1213 |
|
| 1214 |
stk::mesh::EntityId elemId = 1; |
| 1215 |
stk::mesh::EntityIdVector nodeIds = {1, 2, 3, 4}; |
| 1216 |
stk::mesh::declare_element(*bulk, shellPart, elemId, nodeIds); |
| 1217 |
|
| 1218 |
elemId = 2; |
| 1219 |
nodeIds = {2, 5, 6, 3}; |
| 1220 |
stk::mesh::declare_element(*bulk, shellPart, elemId, nodeIds); |
| 1221 |
|
| 1222 |
bulk->modification_end(); |
| 1223 |
|
| 1224 |
if(use_graph) { |
| 1225 |
bulk->initialize_face_adjacent_element_graph(); |
| 1226 |
} |
| 1227 |
|
| 1228 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(bulk->mesh_meta_data().universal_part(), bulk->buckets(side_rank))); |
| 1229 |
|
| 1230 |
bulk->modification_begin(); |
| 1231 |
|
| 1232 |
stk::mesh::Entity elem1 = bulk->get_entity(stk::topology::ELEM_RANK, 1); |
| 1233 |
const unsigned sideOrdinal = 3; |
| 1234 |
stk::mesh::PartVector emptySideParts; |
| 1235 |
|
| 1236 |
stk::mesh::Entity side = bulk->declare_element_side(elem1, sideOrdinal, emptySideParts); |
| 1237 |
bulk->modification_end(); |
| 1238 |
|
| 1239 |
EXPECT_EQ(gold_shell_side_topo, bulk->bucket(side).topology()); |
| 1240 |
|
| 1241 |
EXPECT_EQ(2u, bulk->num_connectivity(side, stk::topology::ELEM_RANK)); |
| 1242 |
} |
| 1243 |
|
| 1244 |
TEST(DeclareElementSide, shell_quad_4_all_face_sides_no_elem_graph) |
| 1245 |
{ |
| 1246 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1247 |
|
| 1248 |
test_shell_quad_4(stk::topology::SHELL_QUAD_4_ALL_FACE_SIDES, stk::topology::FACE_RANK, stk::topology::SHELL_SIDE_BEAM_2, false); |
| 1249 |
} |
| 1250 |
|
| 1251 |
TEST(DeclareElementSide, shell_quad_4_all_face_sides_with_elem_graph) |
| 1252 |
{ |
| 1253 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1254 |
|
| 1255 |
test_shell_quad_4(stk::topology::SHELL_QUAD_4_ALL_FACE_SIDES, stk::topology::FACE_RANK, stk::topology::SHELL_SIDE_BEAM_2, true); |
| 1256 |
} |
| 1257 |
|
| 1258 |
TEST(DeclareElementSide, shell_quad_4_no_elem_graph) |
| 1259 |
{ |
| 1260 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1261 |
|
| 1262 |
test_shell_quad_4(stk::topology::SHELL_QUAD_4, stk::topology::EDGE_RANK, stk::topology::LINE_2, false); |
| 1263 |
} |
| 1264 |
|
| 1265 |
TEST(DeclareElementSide, shell_quad_4_with_elem_graph) |
| 1266 |
{ |
| 1267 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1268 |
|
| 1269 |
test_shell_quad_4(stk::topology::SHELL_QUAD_4, stk::topology::EDGE_RANK, stk::topology::LINE_2, true); |
| 1270 |
} |
| 1271 |
|
| 1272 |
void test_shell_tri_3(stk::topology shell_topo, stk::mesh::EntityRank side_rank, |
| 1273 |
stk::topology gold_shell_side_topo, bool use_graph) |
| 1274 |
{ |
| 1275 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1276 |
/* shell-tri-3 mesh: */ |
| 1277 |
/* 3 */ |
| 1278 |
/* * */ |
| 1279 |
/* /|\ */ |
| 1280 |
/* / | \ */ |
| 1281 |
/* 1* | *4 */ |
| 1282 |
/* \ | / */ |
| 1283 |
/* \|/ */ |
| 1284 |
/* * */ |
| 1285 |
/* 2 */ |
| 1286 |
/* */ |
| 1287 |
|
| 1288 |
EXPECT_EQ(3u, shell_topo.num_nodes()); |
| 1289 |
|
| 1290 |
bulk->modification_begin(); |
| 1291 |
|
| 1292 |
stk::mesh::Part& shellPart = bulk->mesh_meta_data().declare_part_with_topology("shell_part", shell_topo); |
| 1293 |
|
| 1294 |
stk::mesh::EntityId elemId = 1; |
| 1295 |
stk::mesh::EntityIdVector nodeIds = {1, 2, 3}; |
| 1296 |
stk::mesh::declare_element(*bulk, shellPart, elemId, nodeIds); |
| 1297 |
|
| 1298 |
elemId = 2; |
| 1299 |
nodeIds = {2, 4, 3}; |
| 1300 |
stk::mesh::declare_element(*bulk, shellPart, elemId, nodeIds); |
| 1301 |
|
| 1302 |
bulk->modification_end(); |
| 1303 |
|
| 1304 |
if(use_graph) { |
| 1305 |
bulk->initialize_face_adjacent_element_graph(); |
| 1306 |
} |
| 1307 |
|
| 1308 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(bulk->mesh_meta_data().universal_part(), bulk->buckets(side_rank))); |
| 1309 |
|
| 1310 |
bulk->modification_begin(); |
| 1311 |
|
| 1312 |
stk::mesh::Entity elem1 = bulk->get_entity(stk::topology::ELEM_RANK, 1); |
| 1313 |
const unsigned sideOrdinal = 3; |
| 1314 |
stk::mesh::PartVector emptySideParts; |
| 1315 |
|
| 1316 |
stk::mesh::Entity side = bulk->declare_element_side(elem1, sideOrdinal, emptySideParts); |
| 1317 |
bulk->modification_end(); |
| 1318 |
|
| 1319 |
EXPECT_EQ(gold_shell_side_topo, bulk->bucket(side).topology()); |
| 1320 |
|
| 1321 |
EXPECT_EQ(2u, bulk->num_connectivity(side, stk::topology::ELEM_RANK)); |
| 1322 |
} |
| 1323 |
|
| 1324 |
TEST(DeclareElementSide, shell_tri_3_all_face_sides_no_elem_graph) |
| 1325 |
{ |
| 1326 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1327 |
|
| 1328 |
test_shell_tri_3(stk::topology::SHELL_TRI_3_ALL_FACE_SIDES, stk::topology::FACE_RANK, stk::topology::SHELL_SIDE_BEAM_2, false); |
| 1329 |
} |
| 1330 |
|
| 1331 |
TEST(DeclareElementSide, shell_tri_3_all_face_sides_with_elem_graph) |
| 1332 |
{ |
| 1333 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1334 |
|
| 1335 |
test_shell_tri_3(stk::topology::SHELL_TRI_3_ALL_FACE_SIDES, stk::topology::FACE_RANK, stk::topology::SHELL_SIDE_BEAM_2, true); |
| 1336 |
} |
| 1337 |
|
| 1338 |
TEST(DeclareElementSide, shell_tri_3_no_elem_graph) |
| 1339 |
{ |
| 1340 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1341 |
|
| 1342 |
test_shell_tri_3(stk::topology::SHELL_TRI_3, stk::topology::EDGE_RANK, stk::topology::LINE_2, false); |
| 1343 |
} |
| 1344 |
|
| 1345 |
TEST(DeclareElementSide, shell_tri_3_with_elem_graph) |
| 1346 |
{ |
| 1347 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1348 |
|
| 1349 |
test_shell_tri_3(stk::topology::SHELL_TRI_3, stk::topology::EDGE_RANK, stk::topology::LINE_2, true); |
| 1350 |
} |
| 1351 |
|
| 1352 |
void test_shell_tri_3_and_quad_4(stk::topology tri_shell_topo, stk::topology quad_shell_topo, |
| 1353 |
stk::mesh::EntityRank side_rank, |
| 1354 |
stk::topology gold_shell_side_topo, bool use_graph) |
| 1355 |
{ |
| 1356 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1357 |
/* shell-tri-3-quad-4 mesh: */ |
| 1358 |
/* 3 5 */ |
| 1359 |
/* *-----------* */ |
| 1360 |
/* /| | */ |
| 1361 |
/* / | | */ |
| 1362 |
/* 1* | | */ |
| 1363 |
/* \ | | */ |
| 1364 |
/* \| | */ |
| 1365 |
/* *-----------* */ |
| 1366 |
/* 2 4 */ |
| 1367 |
/* */ |
| 1368 |
|
| 1369 |
EXPECT_EQ(3u, tri_shell_topo.num_nodes()); |
| 1370 |
EXPECT_EQ(4u, quad_shell_topo.num_nodes()); |
| 1371 |
|
| 1372 |
bulk->modification_begin(); |
| 1373 |
|
| 1374 |
stk::mesh::Part& triShellPart = bulk->mesh_meta_data().declare_part_with_topology("tri_shell_part", tri_shell_topo); |
| 1375 |
stk::mesh::Part& quadShellPart = bulk->mesh_meta_data().declare_part_with_topology("quad_shell_part", quad_shell_topo); |
| 1376 |
|
| 1377 |
stk::mesh::EntityId elemId = 1; |
| 1378 |
stk::mesh::EntityIdVector nodeIds = {1, 2, 3}; |
| 1379 |
stk::mesh::declare_element(*bulk, triShellPart, elemId, nodeIds); |
| 1380 |
|
| 1381 |
elemId = 2; |
| 1382 |
nodeIds = {2, 4, 5, 3}; |
| 1383 |
stk::mesh::declare_element(*bulk, quadShellPart, elemId, nodeIds); |
| 1384 |
|
| 1385 |
bulk->modification_end(); |
| 1386 |
|
| 1387 |
if(use_graph) { |
| 1388 |
bulk->initialize_face_adjacent_element_graph(); |
| 1389 |
} |
| 1390 |
|
| 1391 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(bulk->mesh_meta_data().universal_part(), bulk->buckets(side_rank))); |
| 1392 |
|
| 1393 |
bulk->modification_begin(); |
| 1394 |
|
| 1395 |
stk::mesh::Entity elem1 = bulk->get_entity(stk::topology::ELEM_RANK, 1); |
| 1396 |
const unsigned sideOrdinal = 3; |
| 1397 |
stk::mesh::PartVector emptySideParts; |
| 1398 |
|
| 1399 |
stk::mesh::Entity side = bulk->declare_element_side(elem1, sideOrdinal, emptySideParts); |
| 1400 |
bulk->modification_end(); |
| 1401 |
|
| 1402 |
EXPECT_EQ(gold_shell_side_topo, bulk->bucket(side).topology()); |
| 1403 |
|
| 1404 |
EXPECT_EQ(2u, bulk->num_connectivity(side, stk::topology::ELEM_RANK)); |
| 1405 |
} |
| 1406 |
|
| 1407 |
TEST(DeclareElementSide, shell_tri_3_and_quad_4_all_face_sides_no_elem_graph) |
| 1408 |
{ |
| 1409 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1410 |
|
| 1411 |
test_shell_tri_3_and_quad_4(stk::topology::SHELL_TRI_3_ALL_FACE_SIDES, |
| 1412 |
stk::topology::SHELL_QUAD_4_ALL_FACE_SIDES, |
| 1413 |
stk::topology::FACE_RANK, stk::topology::SHELL_SIDE_BEAM_2, false); |
| 1414 |
} |
| 1415 |
|
| 1416 |
TEST(DeclareElementSide, shell_tri_3_and_quad_4_all_face_sides_with_elem_graph) |
| 1417 |
{ |
| 1418 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1419 |
|
| 1420 |
test_shell_tri_3_and_quad_4(stk::topology::SHELL_TRI_3_ALL_FACE_SIDES, |
| 1421 |
stk::topology::SHELL_QUAD_4_ALL_FACE_SIDES, |
| 1422 |
stk::topology::FACE_RANK, stk::topology::SHELL_SIDE_BEAM_2, true); |
| 1423 |
} |
| 1424 |
|
| 1425 |
TEST(DeclareElementSide, shell_tri_3_and_quad_4_no_elem_graph) |
| 1426 |
{ |
| 1427 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1428 |
|
| 1429 |
test_shell_tri_3_and_quad_4(stk::topology::SHELL_TRI_3, |
| 1430 |
stk::topology::SHELL_QUAD_4, |
| 1431 |
stk::topology::EDGE_RANK, stk::topology::LINE_2, false); |
| 1432 |
} |
| 1433 |
|
| 1434 |
TEST(DeclareElementSide, shell_tri_3_and_quad_4_with_elem_graph) |
| 1435 |
{ |
| 1436 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1437 |
|
| 1438 |
test_shell_tri_3_and_quad_4(stk::topology::SHELL_TRI_3, |
| 1439 |
stk::topology::SHELL_QUAD_4, |
| 1440 |
stk::topology::EDGE_RANK, stk::topology::LINE_2, true); |
| 1441 |
} |
| 1442 |
|
| 1443 |
TEST(GetSides, hex8) |
| 1444 |
{ |
| 1445 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) > 1) { GTEST_SKIP(); } |
| 1446 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1447 |
|
| 1448 |
stk::io::fill_mesh("generated:1x1x1|sideset:xXyYzZ", *bulk); |
| 1449 |
|
| 1450 |
stk::mesh::Entity elem1 = bulk->get_entity(stk::topology::ELEM_RANK, 1); |
| 1451 |
EXPECT_TRUE(bulk->is_valid(elem1)); |
| 1452 |
EXPECT_EQ(stk::topology::HEX_8, bulk->bucket(elem1).topology()); |
| 1453 |
|
| 1454 |
EXPECT_EQ(6u, stk::mesh::num_sides(*bulk, elem1)); |
| 1455 |
|
| 1456 |
stk::mesh::EntityVector sides = stk::mesh::get_sides(*bulk, elem1); |
| 1457 |
std::vector<stk::mesh::ConnectivityOrdinal> sideOrds = stk::mesh::get_side_ordinals(*bulk, elem1); |
| 1458 |
ASSERT_EQ(6u, sides.size()); |
| 1459 |
ASSERT_EQ(6u, sideOrds.size()); |
| 1460 |
EXPECT_EQ(stk::topology::FACE_RANK, bulk->entity_rank(sides[0])); |
| 1461 |
EXPECT_EQ(stk::topology::FACE_RANK, bulk->entity_rank(sides[1])); |
| 1462 |
} |
| 1463 |
|
| 1464 |
TEST(GetSides, textmesh_shell_quad_4_EdgeSides) |
| 1465 |
{ |
| 1466 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) > 1) { GTEST_SKIP(); } |
| 1467 |
|
| 1468 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1469 |
//shell-quad-4 mesh: |
| 1470 |
// 6 |
| 1471 |
// 3*----*----*9 |
| 1472 |
// | E2 | E4 | |
| 1473 |
// | | | |
| 1474 |
// 2*---5*----*8 |
| 1475 |
// | E1 | E3 | |
| 1476 |
// | | | |
| 1477 |
// 1*----*----*7 |
| 1478 |
// 4 |
| 1479 |
// |
| 1480 |
const std::string meshDesc = |
| 1481 |
"0,1,SHELL_QUAD_4, 1,4,5,2, block_1\n\ |
| 1482 |
0,2,SHELL_QUAD_4, 2,5,6,3, block_1\n\ |
| 1483 |
0,3,SHELL_QUAD_4, 4,7,8,5, block_1\n\ |
| 1484 |
0,4,SHELL_QUAD_4, 5,8,9,6, block_1|sideset:name=surface_1; data=1,3,3,3, 3,4,4,4, 4,5,2,5, 2,6,1,6"; |
| 1485 |
|
| 1486 |
std::vector<double> coords = {0,0,0, 0,1,0, 0,2,0, |
| 1487 |
1,0,0, 1,1,0, 1,2,0, |
| 1488 |
2,0,0, 2,1,0, 2,2,0}; |
| 1489 |
|
| 1490 |
stk::unit_test_util::setup_text_mesh(*bulk, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 1491 |
|
| 1492 |
stk::mesh::Entity elem1 = bulk->get_entity(stk::topology::ELEM_RANK, 1); |
| 1493 |
EXPECT_TRUE(bulk->is_valid(elem1)); |
| 1494 |
EXPECT_EQ(stk::topology::SHELL_QUAD_4, bulk->bucket(elem1).topology()); |
| 1495 |
|
| 1496 |
EXPECT_EQ(2u, stk::mesh::num_sides(*bulk, elem1)); |
| 1497 |
|
| 1498 |
stk::mesh::EntityVector sides = stk::mesh::get_sides(*bulk, elem1); |
| 1499 |
std::vector<stk::mesh::ConnectivityOrdinal> sideOrds = stk::mesh::get_side_ordinals(*bulk, elem1); |
| 1500 |
ASSERT_EQ(2u, sides.size()); |
| 1501 |
ASSERT_EQ(2u, sideOrds.size()); |
| 1502 |
EXPECT_EQ(stk::topology::EDGE_RANK, bulk->entity_rank(sides[0])); |
| 1503 |
EXPECT_EQ(stk::topology::EDGE_RANK, bulk->entity_rank(sides[1])); |
| 1504 |
} |
| 1505 |
|
| 1506 |
TEST(CreateAndWrite, DISABLED_textmesh_shell_quad_4_FullExteriorSkin) |
| 1507 |
{ |
| 1508 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1509 |
const std::string meshDesc = |
| 1510 |
"0,1,SHELL_QUAD_4, 1,4,5,2, block_1\n\ |
| 1511 |
0,2,SHELL_QUAD_4, 2,5,6,3, block_1\n\ |
| 1512 |
0,3,SHELL_QUAD_4, 4,7,8,5, block_1\n\ |
| 1513 |
0,4,SHELL_QUAD_4, 5,8,9,6, block_1|sideset:name=surface_1; data=1,1,2,1,3,1,4,1, 1,2,2,2,3,2,4,2, 1,3,3,3, 3,4,4,4, 4,5,2,5, 2,6,1,6"; |
| 1514 |
|
| 1515 |
std::vector<double> coords = {0,0,0, 0,1,0, 0,2,0, |
| 1516 |
1,0,0, 1,1,0, 1,2,0, |
| 1517 |
2,0,0, 2,1,0, 2,2,0}; |
| 1518 |
|
| 1519 |
stk::unit_test_util::setup_text_mesh(*bulk, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 1520 |
|
| 1521 |
stk::io::write_mesh("shellq4_full_exterior_skin.g", *bulk); |
| 1522 |
} |
| 1523 |
|
| 1524 |
TEST(CreateAndWrite, DISABLED_textmesh_shell_quad_8_EdgeSides) |
| 1525 |
{ |
| 1526 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1527 |
//shell-quad-8 mesh: |
| 1528 |
// 6 12 |
| 1529 |
// 3*----*----*9----*----*15 |
| 1530 |
// | | | |
| 1531 |
// | | | |
| 1532 |
// 2* *8 *14 |
| 1533 |
// | | | |
| 1534 |
// | | | |
| 1535 |
// 1*----*----*7----*----*13 |
| 1536 |
// 4 10 |
| 1537 |
// |
| 1538 |
const std::string meshDesc = |
| 1539 |
"0,1,SHELL_QUAD_8, 1,7,9,3,4,8,6,2, block_1\n\ |
| 1540 |
0,2,SHELL_QUAD_8, 7,13,15,9,10,14,12,8, block_2|sideset:name=surface_1; data=1,1,1,3,2,3,2,6"; |
| 1541 |
//Note: this sideset spec creates a face-side (elem 1, side 1), and 3 edge-sides. |
| 1542 |
//stk-io can't currently read the resulting exodus mesh file if the face-side is present. (Because |
| 1543 |
//the surface-df field gets conflicting sides (restrictions)). |
| 1544 |
|
| 1545 |
std::vector<double> coords = { |
| 1546 |
/*1*/0,0,0, /*2*/0,1,0, /*3*/0,2,0, |
| 1547 |
/*4*/1,0,0, /*6*/1,2,0, |
| 1548 |
/*7*/2,0,0, /*8*/2,1,0, /*9*/2,2,0, |
| 1549 |
/*10*/3,0,0, /*12*/3,2,0, |
| 1550 |
/*13*/4,0,0, /*14*/4,1,0, /*15*/4,2,0}; |
| 1551 |
|
| 1552 |
stk::unit_test_util::setup_text_mesh(*bulk, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 1553 |
|
| 1554 |
stk::io::write_mesh("shellq8_2blk_face_edge_sides.g", *bulk); |
| 1555 |
} |
| 1556 |
|
| 1557 |
TEST(CreateAndWrite, DISABLED_textmesh_shell_tri_3_EdgeSides) |
| 1558 |
{ |
| 1559 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1560 |
//shell-tri-3 mesh: |
| 1561 |
// 4 |
| 1562 |
// 2*---*---*6 |
| 1563 |
// |E1/|E3/| |
| 1564 |
// | / | / | |
| 1565 |
// |/E2|/E4| |
| 1566 |
// 1*---*---*5 |
| 1567 |
// 3 |
| 1568 |
// |
| 1569 |
const std::string meshDesc = |
| 1570 |
"0,1,SHELL_TRI_3, 1,4,2, block_1\n\ |
| 1571 |
0,2,SHELL_TRI_3, 1,3,4, block_1\n\ |
| 1572 |
0,3,SHELL_TRI_3, 3,6,4, block_1\n\ |
| 1573 |
0,4,SHELL_TRI_3, 3,5,6, block_1|sideset:name=surface_1; data=2,3,4,3, 4,4, 3,4,1,4, 1,5"; |
| 1574 |
|
| 1575 |
std::vector<double> coords = {0,0,0, 0,1,0, |
| 1576 |
1,0,0, 1,1,0, |
| 1577 |
2,0,0, 2,1,0}; |
| 1578 |
|
| 1579 |
stk::unit_test_util::setup_text_mesh(*bulk, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 1580 |
|
| 1581 |
stk::io::write_mesh("shellt3_edge_sides.g", *bulk); |
| 1582 |
} |
| 1583 |
|
| 1584 |
TEST(CreateAndWrite, DISABLED_textmesh_shell_tri_3_FullExteriorSkin) |
| 1585 |
{ |
| 1586 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1587 |
const std::string meshDesc = |
| 1588 |
"0,1,SHELL_TRI_3, 1,4,2, block_1\n\ |
| 1589 |
0,2,SHELL_TRI_3, 1,3,4, block_1\n\ |
| 1590 |
0,3,SHELL_TRI_3, 3,6,4, block_1\n\ |
| 1591 |
0,4,SHELL_TRI_3, 3,5,6, block_1|sideset:name=surface_1; data=1,1,2,1,3,1,4,1, 1,2,2,2,3,2,4,2, 2,3,4,3, 4,4, 3,4,1,4, 1,5"; |
| 1592 |
|
| 1593 |
std::vector<double> coords = {0,0,0, 0,1,0, |
| 1594 |
1,0,0, 1,1,0, |
| 1595 |
2,0,0, 2,1,0}; |
| 1596 |
|
| 1597 |
stk::unit_test_util::setup_text_mesh(*bulk, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 1598 |
|
| 1599 |
stk::io::write_mesh("shellt3_full_exterior_skin.g", *bulk); |
| 1600 |
} |
| 1601 |
|
| 1602 |
class InternalSideSet : public stk::unit_test_util::MeshFixture |
| 1603 |
{ |
| 1604 |
protected: |
| 1605 |
void setup_internal_sideset_test() |
| 1606 |
{ |
| 1607 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 1608 |
get_bulk().initialize_face_adjacent_element_graph(); |
| 1609 |
create_sideset_observer(get_bulk()); |
| 1610 |
|
| 1611 |
const std::string meshDesc = "0,1,HEX_8,1,2,3,4,5,6,7,8,block_1\n\ |
| 1612 |
1,2,HEX_8,5,6,7,8,9,10,11,12,block_1"; |
| 1613 |
|
| 1614 |
std::vector<double> coordinates = {0,0,0, 1,0,0, 1,1,0, 0,1,0, |
| 1615 |
0,0,1, 1,0,1, 1,1,1, 0,1,1, |
| 1616 |
0,0,2, 1,0,2, 1,1,2, 0,1,2}; |
| 1617 |
|
| 1618 |
stk::mesh::Part& sidesetPart = get_meta().declare_part(sidesetName, stk::topology::FACE_RANK); |
| 1619 |
get_meta().set_part_id(sidesetPart, 100u); |
| 1620 |
|
| 1621 |
stk::unit_test_util::setup_text_mesh( |
| 1622 |
get_bulk(), stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coordinates)); |
| 1623 |
create_sideset(get_bulk(), sidesetName, "block_1"); |
| 1624 |
|
| 1625 |
std::vector<stk::mesh::SideSet*> sidesets = get_bulk().get_sidesets(); |
| 1626 |
ASSERT_EQ(1u, sidesets.size()); |
| 1627 |
|
| 1628 |
sidesets[0]->set_accept_all_internal_non_coincident_entries(false); |
| 1629 |
} |
| 1630 |
|
| 1631 |
void execute_internal_sideset_test(stk::mesh::EntityId elemId, stk::mesh::ConnectivityOrdinal ordinal) |
| 1632 |
{ |
| 1633 |
std::vector<stk::mesh::SideSet*> sidesets = get_bulk().get_sidesets(); |
| 1634 |
ASSERT_EQ(1u, sidesets.size()); |
| 1635 |
|
| 1636 |
stk::mesh::Part* sidesetPart = get_meta().get_part(sidesetName); |
| 1637 |
ASSERT_TRUE(sidesetPart != nullptr); |
| 1638 |
|
| 1639 |
get_bulk().modification_begin(); |
| 1640 |
stk::mesh::Entity element = get_bulk().get_entity(stk::topology::ELEM_RANK,elemId); |
| 1641 |
|
| 1642 |
if(get_bulk().is_valid(element) && get_bulk().bucket(element).owned()) { |
| 1643 |
sidesets[0]->add(element, ordinal); |
| 1644 |
get_bulk().declare_element_side(element, ordinal, stk::mesh::ConstPartVector{sidesetPart}); |
| 1645 |
} |
| 1646 |
get_bulk().modification_end(); |
| 1647 |
} |
| 1648 |
|
| 1649 |
void test_internal_sideset_test(stk::mesh::EntityId faceId, const std::vector<unsigned>& expectedNumberOfSidesetEntriesPerProc) |
| 1650 |
{ |
| 1651 |
std::vector<stk::mesh::SideSet*> sidesets = get_bulk().get_sidesets(); |
| 1652 |
ASSERT_EQ(1u, sidesets.size()); |
| 1653 |
|
| 1654 |
stk::mesh::Entity face = get_bulk().get_entity(stk::topology::FACE_RANK,faceId); |
| 1655 |
ASSERT_TRUE(get_bulk().is_valid(face)); |
| 1656 |
|
| 1657 |
ASSERT_TRUE(expectedNumberOfSidesetEntriesPerProc.size() >= (unsigned)get_bulk().parallel_size()); |
| 1658 |
EXPECT_EQ(expectedNumberOfSidesetEntriesPerProc[get_bulk().parallel_rank()], sidesets[0]->size()); |
| 1659 |
} |
| 1660 |
|
| 1661 |
void run_internal_sideset_test(stk::mesh::EntityId elemId, stk::mesh::ConnectivityOrdinal ordinal, stk::mesh::EntityId faceId, |
| 1662 |
const std::vector<unsigned>& expectedNumberOfSidesetEntriesPerProc) |
| 1663 |
{ |
| 1664 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 2) {return;} |
| 1665 |
|
| 1666 |
setup_internal_sideset_test(); |
| 1667 |
execute_internal_sideset_test(elemId, ordinal); |
| 1668 |
test_internal_sideset_test(faceId, expectedNumberOfSidesetEntriesPerProc); |
| 1669 |
} |
| 1670 |
|
| 1671 |
std::string sidesetName = "sidesetPart"; |
| 1672 |
}; |
| 1673 |
|
| 1674 |
TEST_F(InternalSideSet, maintainSingleSidedAfterParallelCreationOnProcessorBoundary_onP0) |
| 1675 |
{ |
| 1676 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 2) |
| 1677 |
{ |
| 1678 |
stk::mesh::EntityId elemId = 1; |
| 1679 |
stk::mesh::ConnectivityOrdinal ordinal = 5; |
| 1680 |
stk::mesh::EntityId faceId = 16; |
| 1681 |
std::vector<unsigned> expectedNumberOfSidesetEntriesPerProc = {1, 0}; |
| 1682 |
run_internal_sideset_test(elemId, ordinal, faceId, expectedNumberOfSidesetEntriesPerProc); |
| 1683 |
} |
| 1684 |
} |
| 1685 |
|
| 1686 |
TEST_F(InternalSideSet, maintainSingleSidedAfterParallelCreationOnProcessorBoundary_onP1) |
| 1687 |
{ |
| 1688 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 2) |
| 1689 |
{ |
| 1690 |
stk::mesh::EntityId elemId = 2; |
| 1691 |
stk::mesh::ConnectivityOrdinal ordinal = 4; |
| 1692 |
stk::mesh::EntityId faceId = 16; |
| 1693 |
std::vector<unsigned> expectedNumberOfSidesetEntriesPerProc = {0, 1}; |
| 1694 |
run_internal_sideset_test(elemId, ordinal, faceId, expectedNumberOfSidesetEntriesPerProc); |
| 1695 |
} |
| 1696 |
} |
| 1697 |
|
| 1698 |
class ParallelCoincidence : public stk::unit_test_util::MeshFixture |
| 1699 |
{ |
| 1700 |
public: |
| 1701 |
struct ParallelCoincidenceEntry |
| 1702 |
{ |
| 1703 |
ParallelCoincidenceEntry(const stk::mesh::EntityId elemId_, const stk::mesh::ConnectivityOrdinal ordinal_, const bool expectedCoincidence_) |
| 1704 |
: elemId(elemId_), ordinal(ordinal_), expectedCoincidence(expectedCoincidence_) { } |
| 1705 |
|
| 1706 |
stk::mesh::EntityId elemId; |
| 1707 |
stk::mesh::ConnectivityOrdinal ordinal; |
| 1708 |
bool expectedCoincidence; |
| 1709 |
}; |
| 1710 |
|
| 1711 |
protected: |
| 1712 |
void initialize_mesh() |
| 1713 |
{ |
| 1714 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1715 |
|
| 1716 |
get_bulk().initialize_face_adjacent_element_graph(); |
| 1717 |
create_sideset_observer(get_bulk()); |
| 1718 |
} |
| 1719 |
|
| 1720 |
void setup_coincident_mesh() |
| 1721 |
{ |
| 1722 |
initialize_mesh(); |
| 1723 |
|
| 1724 |
const std::string meshDesc = "0,1,HEX_8,1,2,3,4,5,6,7,8,block_1\n\ |
| 1725 |
1,2,HEX_8,1,2,3,4,9,10,11,12,block_1"; |
| 1726 |
|
| 1727 |
std::vector<double> coordinates = {0,0,0, 1,0,0, 1,1,0, 0,1,0, |
| 1728 |
0,0,1, 1,0,1, 1,1,1, 0,1,1, |
| 1729 |
0,0,2, 1,0,2, 1,1,2, 0,1,2}; |
| 1730 |
|
| 1731 |
stk::unit_test_util::setup_text_mesh( |
| 1732 |
get_bulk(), stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coordinates)); |
| 1733 |
} |
| 1734 |
|
| 1735 |
void setup_non_coincident_mesh() |
| 1736 |
{ |
| 1737 |
initialize_mesh(); |
| 1738 |
|
| 1739 |
const std::string meshDesc = "0,1,HEX_8,1,2,3,4,5,6,7,8,block_1\n\ |
| 1740 |
1,2,HEX_8,5,6,7,8,9,10,11,12,block_1"; |
| 1741 |
|
| 1742 |
std::vector<double> coordinates = {0,0,0, 1,0,0, 1,1,0, 0,1,0, |
| 1743 |
0,0,1, 1,0,1, 1,1,1, 0,1,1, |
| 1744 |
0,0,2, 1,0,2, 1,1,2, 0,1,2}; |
| 1745 |
|
| 1746 |
stk::unit_test_util::setup_text_mesh( |
| 1747 |
get_bulk(), stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coordinates)); |
| 1748 |
} |
| 1749 |
|
| 1750 |
void test_parallel_coincidence(const std::vector<ParallelCoincidenceEntry>& expectedValues) |
| 1751 |
{ |
| 1752 |
std::ostream* outputStream = nullptr; |
| 1753 |
|
| 1754 |
#ifndef NDEBUG |
| 1755 |
std::ostringstream oss; |
| 1756 |
oss << "output." << get_bulk().parallel_rank(); |
| 1757 |
std::string fileName = oss.str(); |
| 1758 |
std::ofstream ofs(fileName, std::ofstream::out); |
| 1759 |
STK_ThrowRequireMsg(ofs.fail() == false, "Failed to open debug file: " << oss.str()); |
| 1760 |
outputStream = &ofs; |
| 1761 |
#endif |
| 1762 |
|
| 1763 |
stk::mesh::SideSetHelper helper(get_bulk(), get_bulk().mesh_meta_data().universal_part(), outputStream); |
| 1764 |
|
| 1765 |
for(const ParallelCoincidenceEntry& entry : expectedValues) { |
| 1766 |
stk::mesh::Entity element = get_bulk().get_entity(stk::topology::ELEM_RANK, entry.elemId); |
| 1767 |
|
| 1768 |
if(get_bulk().is_valid(element) && get_bulk().bucket(element).owned()) { |
| 1769 |
bool isParallelCoincident = helper.element_side_has_coincidence_using_elem_elem_graph(stk::mesh::Entity(), element, entry.ordinal); |
| 1770 |
EXPECT_EQ(entry.expectedCoincidence, isParallelCoincident); |
| 1771 |
} |
| 1772 |
} |
| 1773 |
#ifndef NDEBUG |
| 1774 |
unlink(fileName.c_str()); |
| 1775 |
#endif |
| 1776 |
} |
| 1777 |
}; |
| 1778 |
|
| 1779 |
TEST_F(ParallelCoincidence, checkParallelCoincidenceWithElemElemGraph) |
| 1780 |
{ |
| 1781 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 2) |
| 1782 |
{ |
| 1783 |
setup_coincident_mesh(); |
| 1784 |
|
| 1785 |
std::vector<ParallelCoincidenceEntry> expectedValues; |
| 1786 |
expectedValues.emplace_back(1u, 4u, true); |
| 1787 |
expectedValues.emplace_back(2u, 4u, true); |
| 1788 |
|
| 1789 |
test_parallel_coincidence(expectedValues); |
| 1790 |
} |
| 1791 |
} |
| 1792 |
|
| 1793 |
TEST_F(ParallelCoincidence, checkParallelNonCoincidenceWithElemElemGraph) |
| 1794 |
{ |
| 1795 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 2) |
| 1796 |
{ |
| 1797 |
setup_non_coincident_mesh(); |
| 1798 |
|
| 1799 |
std::vector<ParallelCoincidenceEntry> expectedValues; |
| 1800 |
expectedValues.emplace_back(1u, 5u, false); |
| 1801 |
expectedValues.emplace_back(2u, 4u, false); |
| 1802 |
|
| 1803 |
test_parallel_coincidence(expectedValues); |
| 1804 |
} |
| 1805 |
} |
| 1806 |
|
| 1807 |
TEST(DeclareElementSide, baseScenario_sidesBetweenTwoTriangles) |
| 1808 |
{ |
| 1809 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) > 1) { GTEST_SKIP(); } |
| 1810 |
|
| 1811 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD) |
| 1812 |
.set_spatial_dimension(2).create(); |
| 1813 |
stk::mesh::Part& mySidePart = bulk->mesh_meta_data().declare_part("mySidePart"); |
| 1814 |
std::string meshDesc = |
| 1815 |
"0,1,TRI_3_2D,1,2,3,block_1\n" |
| 1816 |
"0,2,TRI_3_2D,2,4,3,block_1\n" |
| 1817 |
"|dimension:2"; |
| 1818 |
|
| 1819 |
std::vector<double> coords = {0,0, 0,1, 1,0, 1,1}; |
| 1820 |
|
| 1821 |
stk::unit_test_util::setup_text_mesh(*bulk, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 1822 |
|
| 1823 |
const stk::mesh::MetaData& meta = bulk->mesh_meta_data(); |
| 1824 |
EXPECT_EQ(0u, stk::mesh::count_entities(*bulk, meta.side_rank(), meta.universal_part())); |
| 1825 |
|
| 1826 |
stk::mesh::Entity elem1 = bulk->get_entity(stk::topology::ELEM_RANK, 1); |
| 1827 |
stk::mesh::Entity elem2 = bulk->get_entity(stk::topology::ELEM_RANK, 2); |
| 1828 |
|
| 1829 |
stk::mesh::PartVector parts = {&mySidePart}; |
| 1830 |
stk::mesh::Entity side11, side22; |
| 1831 |
{ |
| 1832 |
bulk->modification_begin(); |
| 1833 |
side11 = bulk->declare_element_side(elem1, 1, parts); |
| 1834 |
side22 = bulk->declare_element_side(elem2, 2, parts); |
| 1835 |
bulk->modification_end(); |
| 1836 |
} |
| 1837 |
|
| 1838 |
EXPECT_EQ(1u, stk::mesh::count_entities(*bulk, meta.side_rank(), meta.universal_part())); |
| 1839 |
} |
| 1840 |
|
| 1841 |
TEST(DeclareElementSide, destroyElemAndReconnectElem_sidesBetweenTwoTriangles) |
| 1842 |
{ |
| 1843 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) > 1) { GTEST_SKIP(); } |
| 1844 |
|
| 1845 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD) |
| 1846 |
.set_spatial_dimension(2).create(); |
| 1847 |
stk::mesh::Part& mySidePart = bulk->mesh_meta_data().declare_part("mySidePart"); |
| 1848 |
std::string meshDesc = |
| 1849 |
"0,1,TRI_3_2D,1,2,3,block_1\n" |
| 1850 |
"0,2,TRI_3_2D,2,4,3,block_1\n" |
| 1851 |
"0,3,TRI_3_2D,1,3,5,block_1\n" |
| 1852 |
"0,4,TRI_3_2D,2,6,4,block_1\n" |
| 1853 |
"|dimension:2"; |
| 1854 |
|
| 1855 |
std::vector<double> coords = {0,0, 0,1, 1,0, 1,1, -0.5,0.5, 1.5,0.5}; |
| 1856 |
|
| 1857 |
stk::unit_test_util::setup_text_mesh(*bulk, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 1858 |
|
| 1859 |
const stk::mesh::MetaData& meta = bulk->mesh_meta_data(); |
| 1860 |
EXPECT_EQ(0u, stk::mesh::count_entities(*bulk, meta.side_rank(), meta.universal_part())); |
| 1861 |
|
| 1862 |
stk::mesh::Entity elem1 = bulk->get_entity(stk::topology::ELEM_RANK, 1); |
| 1863 |
stk::mesh::Entity elem2 = bulk->get_entity(stk::topology::ELEM_RANK, 2); |
| 1864 |
|
| 1865 |
stk::mesh::PartVector parts = {&mySidePart}; |
| 1866 |
stk::mesh::Entity side11, side22, side42; |
| 1867 |
{ |
| 1868 |
bulk->modification_begin(); |
| 1869 |
side11 = bulk->declare_element_side(elem1, 1, parts); |
| 1870 |
side22 = bulk->declare_element_side(elem2, 2, parts); |
| 1871 |
bulk->modification_end(); |
| 1872 |
} |
| 1873 |
|
| 1874 |
EXPECT_EQ(1u, stk::mesh::count_entities(*bulk, meta.side_rank(), meta.universal_part())); |
| 1875 |
|
| 1876 |
//now we simulate a "collapse-edge" scenario from the NGS team: |
| 1877 |
//element 2 is between elements 1 and 4. We delete element 2 and |
| 1878 |
//reconnect element 4 (disconnect node 4 and connect to node 3) so |
| 1879 |
//that elements 1 and 4 should now share a "graph edge" in stk-mesh's |
| 1880 |
//elem-elem-graph. |
| 1881 |
stk::mesh::Entity elem4 = bulk->get_entity(stk::topology::ELEM_RANK, 4); |
| 1882 |
{ |
| 1883 |
bulk->modification_begin(); |
| 1884 |
EXPECT_TRUE(bulk->destroy_entity(elem2)); |
| 1885 |
stk::mesh::Entity node4 = bulk->get_entity(stk::topology::NODE_RANK, 4); |
| 1886 |
EXPECT_TRUE(bulk->destroy_relation(elem4, node4, 2)); |
| 1887 |
stk::mesh::Entity node3 = bulk->get_entity(stk::topology::NODE_RANK, 3); |
| 1888 |
bulk->declare_relation(elem4, node3, 2); |
| 1889 |
bulk->modification_end(); |
| 1890 |
} |
| 1891 |
|
| 1892 |
{ |
| 1893 |
bulk->modification_begin(); |
| 1894 |
side11 = bulk->declare_element_side(elem1, 1, parts); |
| 1895 |
side42 = bulk->declare_element_side(elem4, 2, parts); |
| 1896 |
bulk->modification_end(); |
| 1897 |
} |
| 1898 |
|
| 1899 |
//if the elem-elem-graph correctly knows that elements 1 and 4 share a |
| 1900 |
//graph edge, then there should still be just 1 side between them. |
| 1901 |
stk::unit_test::verify_graph_edge_between_elems(*bulk, elem1, elem4); |
| 1902 |
EXPECT_EQ(1u, stk::mesh::count_entities(*bulk, meta.side_rank(), meta.universal_part())); |
| 1903 |
} |
| 1904 |
|
| 1905 |
TEST(Skinning, createSidesForBlock) |
| 1906 |
{ |
| 1907 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1908 |
|
| 1909 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = stk::mesh::MeshBuilder(MPI_COMM_WORLD) |
| 1910 |
.set_spatial_dimension(3) |
| 1911 |
.create(); |
| 1912 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1913 |
stk::mesh::MetaData& meta = bulk.mesh_meta_data(); |
| 1914 |
|
| 1915 |
stk::mesh::Part& block2 = meta.declare_part_with_topology("block_2", stk::topology::HEX_8); |
| 1916 |
stk::mesh::Part& surface1 = meta.declare_part_with_topology("surface_1", stk::topology::QUAD_4); |
| 1917 |
stk::io::put_io_part_attribute(block2); |
| 1918 |
stk::io::put_io_part_attribute(surface1); |
| 1919 |
meta.set_part_id(block2, 2); |
| 1920 |
meta.set_part_id(surface1, 1); |
| 1921 |
|
| 1922 |
stk::io::fill_mesh("generated:2x2x2", bulk); |
| 1923 |
|
| 1924 |
copy_elems_from_block_to_block(bulk, {1, 2}, "block_1", "block_2"); |
| 1925 |
|
| 1926 |
stk::mesh::create_exposed_block_boundary_sides(bulk, block2, stk::mesh::PartVector{&surface1}, (!block2)); |
| 1927 |
EXPECT_EQ(10u, stk::mesh::count_entities(bulk, stk::topology::FACE_RANK, surface1)); |
| 1928 |
} |
| 1929 |
|
| 1930 |
TEST(Skinning, createSidesForShellQuad4Block) |
| 1931 |
{ |
| 1932 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1933 |
std::unique_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1934 |
//shell-quad-4 mesh: |
| 1935 |
// 6 |
| 1936 |
// 3*----*----*9 |
| 1937 |
// | E2 | E4 | |
| 1938 |
// | | | |
| 1939 |
// 2*---5*----*8 |
| 1940 |
// | E1 | E3 | |
| 1941 |
// | | | |
| 1942 |
// 1*----*----*7 |
| 1943 |
// 4 |
| 1944 |
// |
| 1945 |
const std::string meshDesc = |
| 1946 |
"0,1,SHELL_QUAD_4, 1,4,5,2, block_1\n\ |
| 1947 |
0,2,SHELL_QUAD_4, 2,5,6,3, block_1\n\ |
| 1948 |
0,3,SHELL_QUAD_4, 4,7,8,5, block_1\n\ |
| 1949 |
0,4,SHELL_QUAD_4, 5,8,9,6, block_1|sideset:name=surface_1; data=1,3,3,3, 3,4,4,4, 4,5,2,5, 2,6,1,6"; |
| 1950 |
|
| 1951 |
std::vector<double> coords = {0,0,0, 0,1,0, 0,2,0, |
| 1952 |
1,0,0, 1,1,0, 1,2,0, |
| 1953 |
2,0,0, 2,1,0, 2,2,0}; |
| 1954 |
|
| 1955 |
stk::unit_test_util::setup_text_mesh(*bulk, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 1956 |
|
| 1957 |
auto skinPart = bulk->mesh_meta_data().get_part("surface_1"); |
| 1958 |
EXPECT_EQ(0u, stk::mesh::count_entities(*bulk, stk::topology::FACE_RANK, *skinPart)); |
| 1959 |
EXPECT_EQ(8u, stk::mesh::count_entities(*bulk, stk::topology::EDGE_RANK, *skinPart)); |
| 1960 |
} |
| 1961 |
|
| 1962 |
TEST(Skinning, createSidesForShellQuad4BlockExposedBoundary) |
| 1963 |
{ |
| 1964 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1965 |
std::unique_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1966 |
//shell-quad-4 mesh: |
| 1967 |
// 6 |
| 1968 |
// 3*----*----*9 |
| 1969 |
// | E2 | E4 | |
| 1970 |
// | | | |
| 1971 |
// 2*---5*----*8 |
| 1972 |
// | E1 | E3 | |
| 1973 |
// | | | |
| 1974 |
// 1*----*----*7 |
| 1975 |
// 4 |
| 1976 |
// |
| 1977 |
stk::mesh::Part& skinPart = bulk->mesh_meta_data().declare_part("mySkin"); |
| 1978 |
const std::string meshDesc = |
| 1979 |
"0,1,SHELL_QUAD_4, 1,4,5,2, block_1\n\ |
| 1980 |
0,2,SHELL_QUAD_4, 2,5,6,3, block_1\n\ |
| 1981 |
0,3,SHELL_QUAD_4, 4,7,8,5, block_1\n\ |
| 1982 |
0,4,SHELL_QUAD_4, 5,8,9,6, block_1|sideset:name=surface_1"; |
| 1983 |
|
| 1984 |
std::vector<double> coords = {0,0,0, 0,1,0, 0,2,0, |
| 1985 |
1,0,0, 1,1,0, 1,2,0, |
| 1986 |
2,0,0, 2,1,0, 2,2,0}; |
| 1987 |
|
| 1988 |
stk::unit_test_util::setup_text_mesh(*bulk, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 1989 |
|
| 1990 |
stk::mesh::create_exposed_block_boundary_sides(*bulk, bulk->mesh_meta_data().universal_part(), stk::mesh::PartVector{&skinPart}); |
| 1991 |
EXPECT_EQ(8u, stk::mesh::count_entities(*bulk, stk::topology::FACE_RANK, skinPart)); |
| 1992 |
EXPECT_EQ(0u, stk::mesh::count_entities(*bulk, stk::topology::EDGE_RANK, skinPart)); |
| 1993 |
} |
| 1994 |
|
| 1995 |
TEST(Skinning, createSidesForShellQuad8Block) |
| 1996 |
{ |
| 1997 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 1998 |
std::unique_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 1999 |
//shell-quad-8 mesh: |
| 2000 |
// 6 12 |
| 2001 |
// 3*----*----*9----*----*15 |
| 2002 |
// | | | |
| 2003 |
// | | | |
| 2004 |
// 2* *8 *14 |
| 2005 |
// | | | |
| 2006 |
// | | | |
| 2007 |
// 1*----*----*7----*----*13 |
| 2008 |
// 4 10 |
| 2009 |
// |
| 2010 |
stk::mesh::Part& skinPart = bulk->mesh_meta_data().declare_part("mySkin"); |
| 2011 |
const std::string meshDesc = |
| 2012 |
"0,1,SHELL_QUAD_8, 1,7,9,3,4,8,6,2, block_1\n\ |
| 2013 |
0,2,SHELL_QUAD_8, 7,13,15,9,10,14,12,8, block_2|sideset:name=surface_1; data=1,1,1,3,2,3,2,6"; |
| 2014 |
|
| 2015 |
std::vector<double> coords = { |
| 2016 |
/*1*/0,0,0, /*2*/0,1,0, /*3*/0,2,0, |
| 2017 |
/*4*/1,0,0, /*6*/1,2,0, |
| 2018 |
/*7*/2,0,0, /*8*/2,1,0, /*9*/2,2,0, |
| 2019 |
/*10*/3,0,0, /*12*/3,2,0, |
| 2020 |
/*13*/4,0,0, /*14*/4,1,0, /*15*/4,2,0}; |
| 2021 |
|
| 2022 |
stk::unit_test_util::setup_text_mesh(*bulk, stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords)); |
| 2023 |
|
| 2024 |
stk::mesh::create_exposed_block_boundary_sides(*bulk, bulk->mesh_meta_data().universal_part(), stk::mesh::PartVector{&skinPart}); |
| 2025 |
EXPECT_EQ(4u, stk::mesh::count_entities(*bulk, stk::topology::FACE_RANK, skinPart)); |
| 2026 |
} |
| 2027 |
|
| 2028 |
TEST(Skinning, createAllSidesForBlock) |
| 2029 |
{ |
| 2030 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 2031 |
|
| 2032 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = stk::mesh::MeshBuilder(MPI_COMM_WORLD) |
| 2033 |
.set_spatial_dimension(3) |
| 2034 |
.create(); |
| 2035 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 2036 |
stk::mesh::MetaData& meta = bulk.mesh_meta_data(); |
| 2037 |
|
| 2038 |
stk::mesh::Part& block2 = meta.declare_part_with_topology("block_2", stk::topology::HEX_8); |
| 2039 |
stk::mesh::Part& surface1 = meta.declare_part_with_topology("surface_1", stk::topology::QUAD_4); |
| 2040 |
stk::io::put_io_part_attribute(block2); |
| 2041 |
stk::io::put_io_part_attribute(surface1); |
| 2042 |
meta.set_part_id(block2, 2); |
| 2043 |
meta.set_part_id(surface1, 1); |
| 2044 |
|
| 2045 |
stk::io::fill_mesh("generated:2x2x2", bulk); |
| 2046 |
|
| 2047 |
copy_elems_from_block_to_block(bulk, {1, 2}, "block_1", "block_2"); |
| 2048 |
|
| 2049 |
stk::mesh::create_all_block_boundary_sides(bulk, meta.universal_part(), stk::mesh::PartVector{&surface1}); |
| 2050 |
EXPECT_EQ(28u, stk::mesh::count_entities(bulk, stk::topology::FACE_RANK, surface1)); |
| 2051 |
} |
| 2052 |
|
| 2053 |
TEST(Skinning, createAllSidesForBlock_separatePartForInteriorSides) |
| 2054 |
{ |
| 2055 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 2056 |
|
| 2057 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = stk::mesh::MeshBuilder(MPI_COMM_WORLD) |
| 2058 |
.set_spatial_dimension(3) |
| 2059 |
.create(); |
| 2060 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 2061 |
stk::mesh::MetaData& meta = bulk.mesh_meta_data(); |
| 2062 |
|
| 2063 |
stk::mesh::Part& block2 = meta.declare_part_with_topology("block_2", stk::topology::HEX_8); |
| 2064 |
stk::mesh::Part& surface1 = meta.declare_part_with_topology("surface_1", stk::topology::QUAD_4); |
| 2065 |
stk::mesh::Part& interiorSkin = meta.declare_part_with_topology("interiorSkin", stk::topology::QUAD_4); |
| 2066 |
stk::io::put_io_part_attribute(block2); |
| 2067 |
stk::io::put_io_part_attribute(surface1); |
| 2068 |
stk::io::put_io_part_attribute(interiorSkin); |
| 2069 |
meta.set_part_id(block2, 2); |
| 2070 |
meta.set_part_id(surface1, 1); |
| 2071 |
meta.set_part_id(interiorSkin, 2); |
| 2072 |
|
| 2073 |
stk::io::fill_mesh("generated:2x2x2", bulk); |
| 2074 |
|
| 2075 |
copy_elems_from_block_to_block(bulk, {1, 2}, "block_1", "block_2"); |
| 2076 |
|
| 2077 |
stk::mesh::PartVector interiorSkinParts = {&interiorSkin}; |
| 2078 |
stk::mesh::create_all_block_boundary_sides(bulk, meta.universal_part(), stk::mesh::PartVector{&surface1}, &interiorSkinParts); |
| 2079 |
EXPECT_EQ(24u, stk::mesh::count_entities(bulk, stk::topology::FACE_RANK, surface1)); |
| 2080 |
EXPECT_EQ(4u, stk::mesh::count_entities(bulk, stk::topology::FACE_RANK, interiorSkin)); |
| 2081 |
} |
| 2082 |
|
| 2083 |
TEST(CreateAndConvert, read_write_shell_4_all_face_sides) |
| 2084 |
{ |
| 2085 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 2086 |
|
| 2087 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2088 |
|
| 2089 |
const std::string meshDesc = |
| 2090 |
"0,1,SHELL_QUAD_4, 1,2,3,4, block_1 \ |
| 2091 |
|sideset:name=surface_1; data=1,1, 1,2, 1,3, 1,4, 1,5, 1,6; split=topology"; |
| 2092 |
|
| 2093 |
std::vector<double> coords = {0,0,0, 1,0,0, 1,1,0, 0,1,0}; |
| 2094 |
auto fullDesc = stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords); |
| 2095 |
stk::io::StkMeshIoBroker ioBroker; |
| 2096 |
ioBroker.set_enable_all_face_sides_shell_topo(true); |
| 2097 |
stk::io::fill_mesh("textmesh:" + fullDesc, *bulk, ioBroker); |
| 2098 |
|
| 2099 |
stk::mesh::EntityVector entities; |
| 2100 |
stk::mesh::get_entities(*bulk, stk::topology::ELEM_RANK, entities); |
| 2101 |
|
| 2102 |
for (auto entity : entities) { |
| 2103 |
EXPECT_EQ(4u, bulk->num_nodes(entity)) << bulk->entity_key(entity); |
| 2104 |
EXPECT_EQ(0u, bulk->num_edges(entity)) << bulk->entity_key(entity); |
| 2105 |
EXPECT_EQ(6u, bulk->num_faces(entity)) << bulk->entity_key(entity); |
| 2106 |
EXPECT_EQ(6u, bulk->num_sides(entity)) << bulk->entity_key(entity); |
| 2107 |
} |
| 2108 |
|
| 2109 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(bulk->mesh_meta_data().locally_owned_part(), bulk->buckets(stk::topology::EDGE_RANK))); |
| 2110 |
EXPECT_EQ(6u, stk::mesh::count_selected_entities(bulk->mesh_meta_data().locally_owned_part(), bulk->buckets(stk::topology::FACE_RANK))); |
| 2111 |
|
| 2112 |
std::string fileName("shell_quad_4_all_face_sides_test.g"); |
| 2113 |
stk::io::write_mesh(fileName, ioBroker); |
| 2114 |
|
| 2115 |
std::shared_ptr<stk::mesh::BulkData> newBulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2116 |
stk::io::StkMeshIoBroker newIoBroker; |
| 2117 |
newIoBroker.set_bulk_data(*newBulk); |
| 2118 |
size_t index = newIoBroker.add_mesh_database(fileName, stk::io::READ_MESH); |
| 2119 |
newIoBroker.set_active_mesh(index); |
| 2120 |
newIoBroker.set_enable_all_face_sides_shell_topo(true); |
| 2121 |
newIoBroker.create_input_mesh(); |
| 2122 |
newIoBroker.populate_bulk_data(); |
| 2123 |
|
| 2124 |
ASSERT_EQ(newIoBroker.bulk_data_ptr().get(), newBulk.get()); |
| 2125 |
|
| 2126 |
stk::mesh::get_entities(*newBulk, stk::topology::ELEM_RANK, entities); |
| 2127 |
for (auto entity : entities) { |
| 2128 |
EXPECT_EQ(4u, newBulk->num_nodes(entity)) << newBulk->entity_key(entity); |
| 2129 |
EXPECT_EQ(0u, newBulk->num_edges(entity)) << newBulk->entity_key(entity); |
| 2130 |
EXPECT_EQ(6u, newBulk->num_faces(entity)) << newBulk->entity_key(entity); |
| 2131 |
EXPECT_EQ(6u, newBulk->num_sides(entity)) << newBulk->entity_key(entity); |
| 2132 |
} |
| 2133 |
|
| 2134 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(newBulk->mesh_meta_data().locally_owned_part(), newBulk->buckets(stk::topology::EDGE_RANK))); |
| 2135 |
EXPECT_EQ(6u, stk::mesh::count_selected_entities(newBulk->mesh_meta_data().locally_owned_part(), newBulk->buckets(stk::topology::FACE_RANK))); |
| 2136 |
|
| 2137 |
unlink(fileName.c_str()); |
| 2138 |
} |
| 2139 |
|
| 2140 |
class CreateReadAndWrite : public stk::unit_test_util::MeshFixture |
| 2141 |
{ |
| 2142 |
protected: |
| 2143 |
std::string get_meshspec_single_shell_quad_4_with_all_sides() { |
| 2144 |
//shell-quad-4 mesh: |
| 2145 |
// |
| 2146 |
// 4*---3* |
| 2147 |
// | E1 | |
| 2148 |
// | | |
| 2149 |
// 1*---2* |
| 2150 |
// |
| 2151 |
// |
| 2152 |
const std::string meshDesc = |
| 2153 |
"0,1,SHELL_QUAD_4, 1,2,3,4, block_1\n\ |
| 2154 |
|sideset:name=surface_1; data=1,1, 1,2, 1,3, 1,4, 1,5, 1,6; split=topology"; |
| 2155 |
|
| 2156 |
std::vector<double> coords = {0,0,0, 1,0,0, 1,1,0, 0,1,0}; |
| 2157 |
|
| 2158 |
return stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords); |
| 2159 |
} |
| 2160 |
|
| 2161 |
std::string get_meshspec_four_shell_quad_4_with_sideset() { |
| 2162 |
//shell-quad-4 mesh: |
| 2163 |
// 6 |
| 2164 |
// 3*----*----*9 |
| 2165 |
// | E2 | E4 | |
| 2166 |
// | | | |
| 2167 |
// 2*---5*----*8 |
| 2168 |
// | E1 | E3 | |
| 2169 |
// | | | |
| 2170 |
// 1*----*----*7 |
| 2171 |
// 4 |
| 2172 |
// |
| 2173 |
const std::string meshDesc = |
| 2174 |
"0,1,SHELL_QUAD_4, 1,4,5,2, block_1\n\ |
| 2175 |
0,2,SHELL_QUAD_4, 2,5,6,3, block_1\n\ |
| 2176 |
0,3,SHELL_QUAD_4, 4,7,8,5, block_1\n\ |
| 2177 |
0,4,SHELL_QUAD_4, 5,8,9,6, block_1\ |
| 2178 |
|sideset:name=surface_1; data=1,3, 3,3, 3,4, 4,4, 4,5, 2,5, 2,6, 1,6; split=topology"; |
| 2179 |
|
| 2180 |
std::vector<double> coords = {0,0,0, 0,1,0, 0,2,0, |
| 2181 |
1,0,0, 1,1,0, 1,2,0, |
| 2182 |
2,0,0, 2,1,0, 2,2,0}; |
| 2183 |
|
| 2184 |
return stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords); |
| 2185 |
} |
| 2186 |
|
| 2187 |
void create_1_shell_using_ioss_text_mesh(stk::mesh::BulkData& bulk) { |
| 2188 |
stk::io::fill_mesh("textmesh:" + get_meshspec_single_shell_quad_4_with_all_sides(), bulk); |
| 2189 |
} |
| 2190 |
|
| 2191 |
void create_4_shells_using_stk_text_mesh(stk::mesh::BulkData& bulk) { |
| 2192 |
stk::unit_test_util::setup_text_mesh(bulk, get_meshspec_four_shell_quad_4_with_sideset()); |
| 2193 |
} |
| 2194 |
|
| 2195 |
void create_4_shells_using_ioss_text_mesh(stk::mesh::BulkData& bulk) { |
| 2196 |
stk::io::fill_mesh("textmesh:" + get_meshspec_four_shell_quad_4_with_sideset(), bulk); |
| 2197 |
} |
| 2198 |
|
| 2199 |
void check_mesh_properties(stk::mesh::BulkData& bulk, std::vector<unsigned> val) { |
| 2200 |
stk::mesh::EntityVector entities; |
| 2201 |
stk::mesh::get_entities(bulk, stk::topology::ELEM_RANK, entities); |
| 2202 |
|
| 2203 |
for (auto entity : entities) { |
| 2204 |
EXPECT_EQ(val[0], bulk.num_nodes(entity)) << bulk.entity_key(entity); |
| 2205 |
EXPECT_EQ(val[1], bulk.num_edges(entity)) << bulk.entity_key(entity); |
| 2206 |
EXPECT_EQ(val[2], bulk.num_faces(entity)) << bulk.entity_key(entity); |
| 2207 |
EXPECT_EQ(val[3], bulk.num_sides(entity)) << bulk.entity_key(entity); |
| 2208 |
} |
| 2209 |
|
| 2210 |
EXPECT_EQ(val[4], stk::mesh::count_selected_entities(bulk.mesh_meta_data().locally_owned_part(), bulk.buckets(stk::topology::EDGE_RANK))); |
| 2211 |
EXPECT_EQ(val[5], stk::mesh::count_selected_entities(bulk.mesh_meta_data().locally_owned_part(), bulk.buckets(stk::topology::FACE_RANK))); |
| 2212 |
} |
| 2213 |
}; |
| 2214 |
|
| 2215 |
TEST_F(CreateReadAndWrite, DISABLED_stk_textmesh_shell_quad_4_EdgeSides) |
| 2216 |
{ |
| 2217 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 2218 |
|
| 2219 |
std::shared_ptr<stk::mesh::BulkData> bulk1 = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2220 |
std::shared_ptr<stk::mesh::BulkData> bulk2 = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2221 |
|
| 2222 |
std::string fileName("shell_quad_4_edge_sides_test.g"); |
| 2223 |
create_4_shells_using_stk_text_mesh(*bulk1); |
| 2224 |
stk::io::write_mesh(fileName, *bulk1); |
| 2225 |
check_mesh_properties(*bulk1, {4, 2, 0, 2, 8, 0}); |
| 2226 |
|
| 2227 |
stk::io::fill_mesh(fileName, *bulk2); |
| 2228 |
check_mesh_properties(*bulk2, {4, 2, 0, 2, 8, 0}); |
| 2229 |
|
| 2230 |
unlink(fileName.c_str()); |
| 2231 |
} |
| 2232 |
|
| 2233 |
TEST_F(CreateReadAndWrite, ioss_textmesh_shell_quad_4_EdgeSides) |
| 2234 |
{ |
| 2235 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 2236 |
|
| 2237 |
std::shared_ptr<stk::mesh::BulkData> bulk1 = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2238 |
std::shared_ptr<stk::mesh::BulkData> bulk2 = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2239 |
|
| 2240 |
std::string fileName("shell_quad_4_edge_sides_test.g"); |
| 2241 |
create_4_shells_using_ioss_text_mesh(*bulk1); |
| 2242 |
stk::io::write_mesh(fileName, *bulk1); |
| 2243 |
check_mesh_properties(*bulk1, {4, 2, 0, 2, 8, 0}); |
| 2244 |
|
| 2245 |
stk::io::fill_mesh(fileName, *bulk2); |
| 2246 |
check_mesh_properties(*bulk2, {4, 2, 0, 2, 8, 0}); |
| 2247 |
|
| 2248 |
unlink(fileName.c_str()); |
| 2249 |
} |
| 2250 |
|
| 2251 |
TEST_F(CreateReadAndWrite, ioss_textmesh_shell_quad_4_FaceAndEdgeSides) |
| 2252 |
{ |
| 2253 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 2254 |
|
| 2255 |
std::shared_ptr<stk::mesh::BulkData> bulk1 = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2256 |
std::shared_ptr<stk::mesh::BulkData> bulk2 = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2257 |
|
| 2258 |
std::string fileName("shell_quad_4_face_and_edge_sides_test.g"); |
| 2259 |
create_1_shell_using_ioss_text_mesh(*bulk1); |
| 2260 |
stk::io::write_mesh(fileName, *bulk1); |
| 2261 |
check_mesh_properties(*bulk1, {4, 4, 2, 6, 4, 2}); |
| 2262 |
|
| 2263 |
stk::io::fill_mesh(fileName, *bulk2); |
| 2264 |
check_mesh_properties(*bulk2, {4, 4, 2, 6, 4, 2}); |
| 2265 |
|
| 2266 |
unlink(fileName.c_str()); |
| 2267 |
} |
| 2268 |
|
| 2269 |
TEST_F(CreateReadAndWrite, ioss_textmesh_shell_quad_4_write_all_face_sides_read_mixed_sides) |
| 2270 |
{ |
| 2271 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 2272 |
|
| 2273 |
std::shared_ptr<stk::mesh::BulkData> bulk1 = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2274 |
std::shared_ptr<stk::mesh::BulkData> bulk2 = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2275 |
|
| 2276 |
std::string fileName("shell_quad_4_test.g"); |
| 2277 |
std::string meshDesc = get_meshspec_single_shell_quad_4_with_all_sides(); |
| 2278 |
|
| 2279 |
stk::io::StkMeshIoBroker ioBroker1; |
| 2280 |
ioBroker1.set_bulk_data(*bulk1); |
| 2281 |
ioBroker1.set_enable_all_face_sides_shell_topo(true); |
| 2282 |
stk::io::fill_mesh("textmesh:" + meshDesc, *bulk1, ioBroker1); |
| 2283 |
|
| 2284 |
check_mesh_properties(*bulk1, {4, 0, 6, 6, 0, 6}); |
| 2285 |
stk::io::write_mesh(fileName, ioBroker1); |
| 2286 |
|
| 2287 |
stk::io::StkMeshIoBroker ioBroker2; |
| 2288 |
ioBroker2.set_bulk_data(*bulk2); |
| 2289 |
ioBroker2.set_enable_all_face_sides_shell_topo(false); |
| 2290 |
|
| 2291 |
stk::io::fill_mesh(fileName, *bulk2); |
| 2292 |
check_mesh_properties(*bulk2, {4, 4, 2, 6, 4, 2}); |
| 2293 |
|
| 2294 |
unlink(fileName.c_str()); |
| 2295 |
} |
| 2296 |
|
| 2297 |
TEST_F(CreateReadAndWrite, ioss_textmesh_shell_quad_4_write_mixed_sides_read_all_face_sides_read) |
| 2298 |
{ |
| 2299 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 2300 |
|
| 2301 |
std::shared_ptr<stk::mesh::BulkData> bulk1 = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2302 |
std::shared_ptr<stk::mesh::BulkData> bulk2 = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2303 |
|
| 2304 |
std::string fileName("shell_quad_4_test.g"); |
| 2305 |
std::string meshDesc = get_meshspec_single_shell_quad_4_with_all_sides(); |
| 2306 |
|
| 2307 |
stk::io::StkMeshIoBroker ioBroker1; |
| 2308 |
ioBroker1.set_bulk_data(*bulk1); |
| 2309 |
ioBroker1.set_enable_all_face_sides_shell_topo(false); |
| 2310 |
stk::io::fill_mesh("textmesh:" + meshDesc, *bulk1, ioBroker1); |
| 2311 |
|
| 2312 |
check_mesh_properties(*bulk1, {4, 4, 2, 6, 4, 2}); |
| 2313 |
stk::io::write_mesh(fileName, ioBroker1); |
| 2314 |
|
| 2315 |
stk::io::StkMeshIoBroker ioBroker2; |
| 2316 |
ioBroker2.set_bulk_data(*bulk2); |
| 2317 |
ioBroker2.set_enable_all_face_sides_shell_topo(true); |
| 2318 |
|
| 2319 |
auto index = ioBroker2.add_mesh_database(fileName, stk::io::READ_MESH); |
| 2320 |
ioBroker2.set_active_mesh(index); |
| 2321 |
ioBroker2.set_enable_all_face_sides_shell_topo(true); |
| 2322 |
ioBroker2.create_input_mesh(); |
| 2323 |
ioBroker2.populate_bulk_data(); |
| 2324 |
check_mesh_properties(*bulk2, {4, 0, 6, 6, 0, 6}); |
| 2325 |
|
| 2326 |
unlink(fileName.c_str()); |
| 2327 |
} |
| 2328 |
|
| 2329 |
TEST(DeclareElementSide, hex8_no_elem_graph) |
| 2330 |
{ |
| 2331 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 2332 |
|
| 2333 |
std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); |
| 2334 |
|
| 2335 |
bulk->modification_begin(); |
| 2336 |
|
| 2337 |
stk::mesh::Part& hex8Part = bulk->mesh_meta_data().declare_part_with_topology("hex8_part", stk::topology::HEX_8); |
| 2338 |
|
| 2339 |
stk::mesh::EntityId elemId = 1; |
| 2340 |
stk::mesh::EntityIdVector nodeIds = {1, 2, 3, 4, 5, 6, 7, 8}; |
| 2341 |
stk::mesh::declare_element(*bulk, hex8Part, elemId, nodeIds); |
| 2342 |
|
| 2343 |
elemId = 2; |
| 2344 |
nodeIds = {5, 6, 7, 8, 9, 10, 11, 12}; |
| 2345 |
stk::mesh::declare_element(*bulk, hex8Part, elemId, nodeIds); |
| 2346 |
|
| 2347 |
bulk->modification_end(); |
| 2348 |
|
| 2349 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(bulk->mesh_meta_data().universal_part(), bulk->buckets(stk::topology::FACE_RANK))); |
| 2350 |
|
| 2351 |
bulk->modification_begin(); |
| 2352 |
|
| 2353 |
stk::mesh::Entity elem1 = bulk->get_entity(stk::topology::ELEM_RANK, 1); |
| 2354 |
const unsigned sideOrdinal = 5; |
| 2355 |
stk::mesh::PartVector emptySideParts; |
| 2356 |
|
| 2357 |
stk::mesh::EntityVector sideNodes = { |
| 2358 |
bulk->get_entity(stk::topology::NODE_RANK, 5), |
| 2359 |
bulk->get_entity(stk::topology::NODE_RANK, 6), |
| 2360 |
bulk->get_entity(stk::topology::NODE_RANK, 7), |
| 2361 |
bulk->get_entity(stk::topology::NODE_RANK, 8) |
| 2362 |
}; |
| 2363 |
stk::mesh::ConnectivityOrdinal expectedSideOrdinal = sideOrdinal; |
| 2364 |
stk::mesh::Permutation expectedPerm = static_cast<stk::mesh::Permutation>(0); |
| 2365 |
std::cout<<"checking elem1/sideNodes"<<std::endl; |
| 2366 |
check_ordinal_and_permutation(*bulk, elem1, stk::topology::FACE_RANK, sideNodes, expectedSideOrdinal, expectedPerm); |
| 2367 |
|
| 2368 |
stk::mesh::Entity elem2 = bulk->get_entity(stk::topology::ELEM_RANK, 2); |
| 2369 |
expectedSideOrdinal = 4; |
| 2370 |
stk::mesh::EntityVector reversedSideNodes = { |
| 2371 |
bulk->get_entity(stk::topology::NODE_RANK, 5), |
| 2372 |
bulk->get_entity(stk::topology::NODE_RANK, 8), |
| 2373 |
bulk->get_entity(stk::topology::NODE_RANK, 7), |
| 2374 |
bulk->get_entity(stk::topology::NODE_RANK, 6) |
| 2375 |
}; |
| 2376 |
expectedPerm = static_cast<stk::mesh::Permutation>(0); |
| 2377 |
std::cout<<"checking elem2/reversedSideNodes"<<std::endl; |
| 2378 |
check_ordinal_and_permutation(*bulk, elem2, stk::topology::FACE_RANK, reversedSideNodes, expectedSideOrdinal, expectedPerm); |
| 2379 |
|
| 2380 |
expectedPerm = static_cast<stk::mesh::Permutation>(4); |
| 2381 |
std::cout<<"checking elem2/sideNodes"<<std::endl; |
| 2382 |
check_ordinal_and_permutation(*bulk, elem2, stk::topology::FACE_RANK, sideNodes, expectedSideOrdinal, expectedPerm); |
| 2383 |
|
| 2384 |
|
| 2385 |
stk::mesh::Entity side = bulk->declare_element_side(elem1, sideOrdinal, emptySideParts); |
| 2386 |
bulk->modification_end(); |
| 2387 |
|
| 2388 |
EXPECT_EQ(stk::topology::QUAD_4, bulk->bucket(side).topology()); |
| 2389 |
|
| 2390 |
EXPECT_EQ(2u, bulk->num_connectivity(side, stk::topology::ELEM_RANK)); |
| 2391 |
} |
| 2392 |
|
| 2393 |
|
| 2394 |
TEST(ShellConnection, test_is_shell_side) |
| 2395 |
{ |
| 2396 |
stk::topology shellTri3AllFaceSides = stk::topology::SHELL_TRI_3_ALL_FACE_SIDES; |
| 2397 |
|
| 2398 |
EXPECT_FALSE(stk::mesh::impl::is_shell_side(shellTri3AllFaceSides, 0)); |
| 2399 |
EXPECT_FALSE(stk::mesh::impl::is_shell_side(shellTri3AllFaceSides, 1)); |
| 2400 |
|
| 2401 |
EXPECT_TRUE(stk::mesh::impl::is_shell_side(shellTri3AllFaceSides, 2)); |
| 2402 |
EXPECT_TRUE(stk::mesh::impl::is_shell_side(shellTri3AllFaceSides, 3)); |
| 2403 |
EXPECT_TRUE(stk::mesh::impl::is_shell_side(shellTri3AllFaceSides, 4)); |
| 2404 |
|
| 2405 |
stk::topology shellTri3 = stk::topology::SHELL_TRI_3; |
| 2406 |
|
| 2407 |
EXPECT_FALSE(stk::mesh::impl::is_shell_side(shellTri3, 0)); |
| 2408 |
EXPECT_FALSE(stk::mesh::impl::is_shell_side(shellTri3, 1)); |
| 2409 |
|
| 2410 |
EXPECT_TRUE(stk::mesh::impl::is_shell_side(shellTri3, 2)); |
| 2411 |
EXPECT_TRUE(stk::mesh::impl::is_shell_side(shellTri3, 3)); |
| 2412 |
EXPECT_TRUE(stk::mesh::impl::is_shell_side(shellTri3, 4)); |
| 2413 |
|
| 2414 |
stk::topology hex8 = stk::topology::HEX_8; |
| 2415 |
|
| 2416 |
for(unsigned ordinal = 0; ordinal < hex8.num_sides(); ordinal++) { |
| 2417 |
EXPECT_FALSE(stk::mesh::impl::is_shell_side(hex8, ordinal)); |
| 2418 |
} |
| 2419 |
} |
| 2420 |
|
| 2421 |
TEST(ShellConnection, test_get_shell_configuration) |
| 2422 |
{ |
| 2423 |
stk::topology shellTri3AllFaceSides = stk::topology::SHELL_TRI_3_ALL_FACE_SIDES; |
| 2424 |
stk::topology shellTri3 = stk::topology::SHELL_TRI_3; |
| 2425 |
stk::topology hex8 = stk::topology::HEX_8; |
| 2426 |
|
| 2427 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::INVALID, stk::mesh::impl::get_shell_configuration(hex8, 0, hex8, 0)); |
| 2428 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::INVALID, stk::mesh::impl::get_shell_configuration(hex8, 0, shellTri3, 0)); |
| 2429 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::INVALID, stk::mesh::impl::get_shell_configuration(hex8, 0, shellTri3AllFaceSides, 0)); |
| 2430 |
|
| 2431 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::STACKED, stk::mesh::impl::get_shell_configuration(shellTri3AllFaceSides, 0, shellTri3AllFaceSides, 0)); |
| 2432 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::STACKED, stk::mesh::impl::get_shell_configuration(shellTri3AllFaceSides, 0, shellTri3AllFaceSides, 1)); |
| 2433 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::STACKED, stk::mesh::impl::get_shell_configuration(shellTri3AllFaceSides, 1, shellTri3AllFaceSides, 0)); |
| 2434 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::STACKED, stk::mesh::impl::get_shell_configuration(shellTri3AllFaceSides, 1, shellTri3AllFaceSides, 1)); |
| 2435 |
|
| 2436 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::STACKED, stk::mesh::impl::get_shell_configuration(shellTri3, 0, shellTri3AllFaceSides, 0)); |
| 2437 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::STACKED, stk::mesh::impl::get_shell_configuration(shellTri3, 0, shellTri3AllFaceSides, 1)); |
| 2438 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::STACKED, stk::mesh::impl::get_shell_configuration(shellTri3, 1, shellTri3AllFaceSides, 0)); |
| 2439 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::STACKED, stk::mesh::impl::get_shell_configuration(shellTri3, 1, shellTri3AllFaceSides, 1)); |
| 2440 |
|
| 2441 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::INVALID, stk::mesh::impl::get_shell_configuration(shellTri3AllFaceSides, 0, shellTri3AllFaceSides, 2)); |
| 2442 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::INVALID, stk::mesh::impl::get_shell_configuration(shellTri3AllFaceSides, 1, shellTri3AllFaceSides, 3)); |
| 2443 |
|
| 2444 |
for(unsigned ordinal1 = 2; ordinal1 < 5; ordinal1++) { |
| 2445 |
for(unsigned ordinal2 = 2; ordinal2 < 5; ordinal2++) { |
| 2446 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::PAVED, |
| 2447 |
stk::mesh::impl::get_shell_configuration(shellTri3AllFaceSides, ordinal1, shellTri3AllFaceSides, ordinal2)); |
| 2448 |
|
| 2449 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::PAVED, |
| 2450 |
stk::mesh::impl::get_shell_configuration(shellTri3, ordinal1, shellTri3, ordinal2)); |
| 2451 |
|
| 2452 |
EXPECT_EQ(stk::mesh::impl::ShellConnectionConfiguration::PAVED, |
| 2453 |
stk::mesh::impl::get_shell_configuration(shellTri3, ordinal1, shellTri3AllFaceSides, ordinal2)); |
| 2454 |
} |
| 2455 |
} |
| 2456 |
} |
| 2457 |
|
| 2458 |
TEST(ShellConnection, test_is_shell_configuration_valid_for_side_connection) |
| 2459 |
{ |
| 2460 |
stk::topology shellTri3 = stk::topology::SHELL_TRI_3; |
| 2461 |
stk::topology shellTri3AllFaceSides = stk::topology::SHELL_TRI_3_ALL_FACE_SIDES; |
| 2462 |
stk::topology shellQuad4 = stk::topology::SHELL_QUAD_4; |
| 2463 |
stk::topology shellQuad4AllFaceSides = stk::topology::SHELL_QUAD_4_ALL_FACE_SIDES; |
| 2464 |
stk::topology hex8 = stk::topology::HEX_8; |
| 2465 |
|
| 2466 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(hex8, 0, hex8, 0)); |
| 2467 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(hex8, 0, shellTri3, 0)); |
| 2468 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(hex8, 0, shellTri3AllFaceSides, 0)); |
| 2469 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(hex8, 0, shellQuad4AllFaceSides, 0)); |
| 2470 |
|
| 2471 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 0, shellTri3, 0)); |
| 2472 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 0, shellTri3, 1)); |
| 2473 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 1, shellTri3, 0)); |
| 2474 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 1, shellTri3, 1)); |
| 2475 |
|
| 2476 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 0, shellTri3AllFaceSides, 0)); |
| 2477 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 0, shellTri3AllFaceSides, 1)); |
| 2478 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 1, shellTri3AllFaceSides, 0)); |
| 2479 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 1, shellTri3AllFaceSides, 1)); |
| 2480 |
|
| 2481 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4AllFaceSides, 0, shellQuad4AllFaceSides, 0)); |
| 2482 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4AllFaceSides, 0, shellQuad4AllFaceSides, 1)); |
| 2483 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4AllFaceSides, 1, shellQuad4AllFaceSides, 0)); |
| 2484 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4AllFaceSides, 1, shellQuad4AllFaceSides, 1)); |
| 2485 |
|
| 2486 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 0, shellTri3AllFaceSides, 0), std::logic_error); |
| 2487 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 0, shellTri3AllFaceSides, 1), std::logic_error); |
| 2488 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 1, shellTri3AllFaceSides, 0), std::logic_error); |
| 2489 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 1, shellTri3AllFaceSides, 1), std::logic_error); |
| 2490 |
|
| 2491 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 0, shellQuad4, 0)); |
| 2492 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 0, shellQuad4, 1)); |
| 2493 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 1, shellQuad4, 0)); |
| 2494 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 1, shellQuad4, 1)); |
| 2495 |
|
| 2496 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 0, shellQuad4AllFaceSides, 0), std::logic_error); |
| 2497 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 0, shellQuad4AllFaceSides, 1), std::logic_error); |
| 2498 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 1, shellQuad4AllFaceSides, 0), std::logic_error); |
| 2499 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 1, shellQuad4AllFaceSides, 1), std::logic_error); |
| 2500 |
|
| 2501 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 0, shellQuad4, 0), std::logic_error); |
| 2502 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 0, shellQuad4, 1), std::logic_error); |
| 2503 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 1, shellQuad4, 0), std::logic_error); |
| 2504 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 1, shellQuad4, 1), std::logic_error); |
| 2505 |
|
| 2506 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 0, shellQuad4AllFaceSides, 0)); |
| 2507 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 0, shellQuad4AllFaceSides, 1)); |
| 2508 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 1, shellQuad4AllFaceSides, 0)); |
| 2509 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 1, shellQuad4AllFaceSides, 1)); |
| 2510 |
|
| 2511 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 0, shellTri3, 2)); |
| 2512 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, 1, shellTri3, 3)); |
| 2513 |
|
| 2514 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 0, shellTri3AllFaceSides, 2)); |
| 2515 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, 1, shellTri3AllFaceSides, 3)); |
| 2516 |
|
| 2517 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4AllFaceSides, 0, shellQuad4AllFaceSides, 2)); |
| 2518 |
EXPECT_FALSE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4AllFaceSides, 1, shellQuad4AllFaceSides, 3)); |
| 2519 |
|
| 2520 |
// tri/tri testing |
| 2521 |
for(unsigned ordinal1 = 2; ordinal1 < 5; ordinal1++) { |
| 2522 |
for(unsigned ordinal2 = 2; ordinal2 < 5; ordinal2++) { |
| 2523 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, ordinal1, shellTri3AllFaceSides, ordinal2)); |
| 2524 |
|
| 2525 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, ordinal1, shellTri3, ordinal2)); |
| 2526 |
|
| 2527 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, ordinal1, shellTri3AllFaceSides, ordinal2), std::logic_error); |
| 2528 |
|
| 2529 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, ordinal1, shellTri3, ordinal2), std::logic_error); |
| 2530 |
} |
| 2531 |
} |
| 2532 |
|
| 2533 |
// tri/quad testing |
| 2534 |
for(unsigned ordinal1 = 2; ordinal1 < 5; ordinal1++) { |
| 2535 |
for(unsigned ordinal2 = 2; ordinal2 < 6; ordinal2++) { |
| 2536 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, ordinal1, shellQuad4AllFaceSides, ordinal2)); |
| 2537 |
|
| 2538 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, ordinal1, shellQuad4, ordinal2)); |
| 2539 |
|
| 2540 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3, ordinal1, shellQuad4AllFaceSides, ordinal2), std::logic_error); |
| 2541 |
|
| 2542 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellTri3AllFaceSides, ordinal1, shellQuad4, ordinal2), std::logic_error); |
| 2543 |
} |
| 2544 |
} |
| 2545 |
|
| 2546 |
// quad/tri testing |
| 2547 |
for(unsigned ordinal1 = 2; ordinal1 < 6; ordinal1++) { |
| 2548 |
for(unsigned ordinal2 = 2; ordinal2 < 5; ordinal2++) { |
| 2549 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4AllFaceSides, ordinal1, shellTri3AllFaceSides, ordinal2)); |
| 2550 |
|
| 2551 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4, ordinal1, shellTri3, ordinal2)); |
| 2552 |
|
| 2553 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4, ordinal1, shellTri3AllFaceSides, ordinal2), std::logic_error); |
| 2554 |
|
| 2555 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4AllFaceSides, ordinal1, shellTri3, ordinal2), std::logic_error); |
| 2556 |
} |
| 2557 |
} |
| 2558 |
|
| 2559 |
// quad/quad testing |
| 2560 |
for(unsigned ordinal1 = 2; ordinal1 < 6; ordinal1++) { |
| 2561 |
for(unsigned ordinal2 = 2; ordinal2 < 6; ordinal2++) { |
| 2562 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4AllFaceSides, ordinal1, shellQuad4AllFaceSides, ordinal2)); |
| 2563 |
|
| 2564 |
EXPECT_TRUE(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4, ordinal1, shellQuad4, ordinal2)); |
| 2565 |
|
| 2566 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4, ordinal1, shellQuad4AllFaceSides, ordinal2), std::logic_error); |
| 2567 |
|
| 2568 |
EXPECT_THROW(stk::mesh::impl::is_shell_configuration_valid_for_side_connection(shellQuad4AllFaceSides, ordinal1, shellQuad4, ordinal2), std::logic_error); |
| 2569 |
} |
| 2570 |
} |
| 2571 |
} |
| 2572 |
|
| 2573 |
struct ConnectionInfo { |
| 2574 |
unsigned sideIndex; |
| 2575 |
stk::mesh::Permutation elemPerm; |
| 2576 |
unsigned otherSideIndex; |
| 2577 |
stk::mesh::Permutation otherElemPerm; |
| 2578 |
|
| 2579 |
ConnectionInfo(unsigned sideIndex_, stk::mesh::Permutation elemPerm_, |
| 2580 |
unsigned otherSideIndex_, stk::mesh::Permutation otherElemPerm_) |
| 2581 |
: sideIndex(sideIndex_) |
| 2582 |
, elemPerm(elemPerm_) |
| 2583 |
, otherSideIndex(otherSideIndex_) |
| 2584 |
, otherElemPerm(otherElemPerm_) |
| 2585 |
{ } |
| 2586 |
}; |
| 2587 |
|
| 2588 |
template<typename T> |
| 2589 |
bool is_coincident_shell_shell_connection(const stk::topology& elemTopology, |
| 2590 |
const stk::topology& otherElemTopology, |
| 2591 |
const std::vector<ConnectionInfo>& connInfoVec, |
| 2592 |
const T otherElemLocalId) |
| 2593 |
{ |
| 2594 |
assert(elemTopology.is_shell() && otherElemTopology.is_shell()); |
| 2595 |
|
| 2596 |
stk::mesh::impl::SortedKeyBoolPairVector<T> hasShellFaceFaceConfiguration; |
| 2597 |
hasShellFaceFaceConfiguration.clear(); |
| 2598 |
|
| 2599 |
bool isCoincidentShellShellConnection = false; |
| 2600 |
|
| 2601 |
for(const ConnectionInfo& connInfo : connInfoVec) { |
| 2602 |
unsigned sideIndex = connInfo.sideIndex; |
| 2603 |
bool isShellFaceElem = stk::mesh::impl::is_shell_face_side(elemTopology, sideIndex); |
| 2604 |
|
| 2605 |
hasShellFaceFaceConfiguration.set_if_not_already_set(otherElemLocalId, false); |
| 2606 |
|
| 2607 |
unsigned otherSideIndex = connInfo.otherSideIndex; |
| 2608 |
bool isShellFaceOtherElem = stk::mesh::impl::is_shell_face_side(otherElemTopology, otherSideIndex); |
| 2609 |
|
| 2610 |
if(isShellFaceElem && isShellFaceOtherElem) { |
| 2611 |
hasShellFaceFaceConfiguration.set(otherElemLocalId, true); |
| 2612 |
} |
| 2613 |
|
| 2614 |
if(hasShellFaceFaceConfiguration.get(otherElemLocalId) && |
| 2615 |
stk::mesh::impl::is_shell_configuration_valid_for_side_connection(elemTopology, sideIndex, otherElemTopology, otherSideIndex)) { |
| 2616 |
isCoincidentShellShellConnection = true; |
| 2617 |
} |
| 2618 |
} |
| 2619 |
|
| 2620 |
return isCoincidentShellShellConnection; |
| 2621 |
} |
| 2622 |
|
| 2623 |
template<typename T> |
| 2624 |
bool is_coincident_connection(const stk::topology& elemTopology, |
| 2625 |
const stk::topology& otherElemTopology, |
| 2626 |
const std::vector<ConnectionInfo>& connInfoVec, |
| 2627 |
const T otherElemLocalId) |
| 2628 |
{ |
| 2629 |
if(elemTopology.is_shell() && otherElemTopology.is_shell()) { |
| 2630 |
return is_coincident_shell_shell_connection<T>(elemTopology, otherElemTopology, connInfoVec, otherElemLocalId); |
| 2631 |
} |
| 2632 |
|
| 2633 |
bool isCoincidentConnection = false; |
| 2634 |
|
| 2635 |
for(const ConnectionInfo& connInfo : connInfoVec) { |
| 2636 |
unsigned sideIndex = connInfo.sideIndex; |
| 2637 |
const stk::mesh::Permutation perm = connInfo.elemPerm; |
| 2638 |
|
| 2639 |
unsigned otherSideIndex = connInfo.otherSideIndex; |
| 2640 |
const stk::mesh::Permutation otherPerm = connInfo.otherElemPerm; |
| 2641 |
|
| 2642 |
const bool elemIsPos = elemTopology.side_topology(sideIndex).is_positive_polarity(perm); |
| 2643 |
const bool otherElemIsPos = otherElemTopology.side_topology(otherSideIndex).is_positive_polarity(otherPerm); |
| 2644 |
|
| 2645 |
if((elemIsPos == otherElemIsPos) && |
| 2646 |
(elemTopology.side_topology(sideIndex) == otherElemTopology.side_topology(otherSideIndex))) { |
| 2647 |
isCoincidentConnection = true; |
| 2648 |
} |
| 2649 |
} |
| 2650 |
|
| 2651 |
return isCoincidentConnection; |
| 2652 |
} |
| 2653 |
|
| 2654 |
TEST(ShellConnection, test_is_coincident_connection) |
| 2655 |
{ |
| 2656 |
// Characterization test for how coincidence is now defined |
| 2657 |
|
| 2658 |
unsigned otherElemLocalId = 1; |
| 2659 |
std::vector<ConnectionInfo> connInfoVec; |
| 2660 |
|
| 2661 |
// Stacked face-face |
| 2662 |
connInfoVec.clear(); |
| 2663 |
connInfoVec.emplace_back(0, static_cast<stk::mesh::Permutation>(0), 0, static_cast<stk::mesh::Permutation>(0)); |
| 2664 |
connInfoVec.emplace_back(1, static_cast<stk::mesh::Permutation>(0), 1, static_cast<stk::mesh::Permutation>(0)); |
| 2665 |
connInfoVec.emplace_back(2, static_cast<stk::mesh::Permutation>(0), 2, static_cast<stk::mesh::Permutation>(0)); |
| 2666 |
connInfoVec.emplace_back(3, static_cast<stk::mesh::Permutation>(0), 3, static_cast<stk::mesh::Permutation>(0)); |
| 2667 |
connInfoVec.emplace_back(4, static_cast<stk::mesh::Permutation>(0), 4, static_cast<stk::mesh::Permutation>(0)); |
| 2668 |
connInfoVec.emplace_back(5, static_cast<stk::mesh::Permutation>(0), 5, static_cast<stk::mesh::Permutation>(0)); |
| 2669 |
EXPECT_TRUE(is_coincident_connection(stk::topology::SHELL_TRI_3, stk::topology::SHELL_TRI_3, connInfoVec, otherElemLocalId)); |
| 2670 |
|
| 2671 |
// Stacked reverse face-face |
| 2672 |
connInfoVec.clear(); |
| 2673 |
connInfoVec.emplace_back(0, static_cast<stk::mesh::Permutation>(0), 0, static_cast<stk::mesh::Permutation>(4)); |
| 2674 |
connInfoVec.emplace_back(1, static_cast<stk::mesh::Permutation>(0), 1, static_cast<stk::mesh::Permutation>(4)); |
| 2675 |
connInfoVec.emplace_back(2, static_cast<stk::mesh::Permutation>(0), 2, static_cast<stk::mesh::Permutation>(1)); |
| 2676 |
connInfoVec.emplace_back(3, static_cast<stk::mesh::Permutation>(0), 3, static_cast<stk::mesh::Permutation>(1)); |
| 2677 |
connInfoVec.emplace_back(4, static_cast<stk::mesh::Permutation>(0), 4, static_cast<stk::mesh::Permutation>(1)); |
| 2678 |
connInfoVec.emplace_back(5, static_cast<stk::mesh::Permutation>(0), 5, static_cast<stk::mesh::Permutation>(1)); |
| 2679 |
EXPECT_TRUE(is_coincident_connection(stk::topology::SHELL_TRI_3, stk::topology::SHELL_TRI_3, connInfoVec, otherElemLocalId)); |
| 2680 |
|
| 2681 |
// Paved shells .. opposite edge orientation |
| 2682 |
connInfoVec.clear(); |
| 2683 |
connInfoVec.emplace_back(2, static_cast<stk::mesh::Permutation>(0), 3, static_cast<stk::mesh::Permutation>(1)); |
| 2684 |
EXPECT_FALSE(is_coincident_connection(stk::topology::SHELL_TRI_3, stk::topology::SHELL_TRI_3, connInfoVec, otherElemLocalId)); |
| 2685 |
|
| 2686 |
// Paved shells .. same edge orientation |
| 2687 |
connInfoVec.clear(); |
| 2688 |
connInfoVec.emplace_back(2, static_cast<stk::mesh::Permutation>(0), 3, static_cast<stk::mesh::Permutation>(0)); |
| 2689 |
EXPECT_FALSE(is_coincident_connection(stk::topology::SHELL_TRI_3, stk::topology::SHELL_TRI_3, connInfoVec, otherElemLocalId)); |
| 2690 |
|
| 2691 |
// Invalid shell edge to edge face |
| 2692 |
connInfoVec.clear(); |
| 2693 |
connInfoVec.emplace_back(2, static_cast<stk::mesh::Permutation>(0), 0, static_cast<stk::mesh::Permutation>(0)); |
| 2694 |
EXPECT_FALSE(is_coincident_connection(stk::topology::SHELL_TRI_3, stk::topology::SHELL_TRI_3, connInfoVec, otherElemLocalId)); |
| 2695 |
|
| 2696 |
// Hex8 shell .. same orientation |
| 2697 |
connInfoVec.clear(); |
| 2698 |
connInfoVec.emplace_back(0, static_cast<stk::mesh::Permutation>(0), 0, static_cast<stk::mesh::Permutation>(0)); |
| 2699 |
EXPECT_TRUE(is_coincident_connection(stk::topology::HEX_8, stk::topology::SHELL_QUAD_4, connInfoVec, otherElemLocalId)); |
| 2700 |
|
| 2701 |
// Hex8 shell .. opposite orientation |
| 2702 |
connInfoVec.clear(); |
| 2703 |
connInfoVec.emplace_back(0, static_cast<stk::mesh::Permutation>(0), 0, static_cast<stk::mesh::Permutation>(4)); |
| 2704 |
EXPECT_FALSE(is_coincident_connection(stk::topology::HEX_8, stk::topology::SHELL_QUAD_4, connInfoVec, otherElemLocalId)); |
| 2705 |
|
| 2706 |
// Invalid Hex8 face to shell edge |
| 2707 |
connInfoVec.clear(); |
| 2708 |
connInfoVec.emplace_back(0, static_cast<stk::mesh::Permutation>(0), 2, static_cast<stk::mesh::Permutation>(0)); |
| 2709 |
EXPECT_FALSE(is_coincident_connection(stk::topology::HEX_8, stk::topology::SHELL_QUAD_4, connInfoVec, otherElemLocalId)); |
| 2710 |
} |
| 2711 |
|