| 1 |
#include <gtest/gtest.h> |
| 2 |
|
| 3 |
#include <vector> |
| 4 |
#include <algorithm> |
| 5 |
#include <stdlib.h> |
| 6 |
|
| 7 |
#include <stk_topology/topology.hpp> |
| 8 |
#include <stk_mesh/base/BulkData.hpp> |
| 9 |
#include <stk_mesh/base/MeshBuilder.hpp> |
| 10 |
#include <stk_mesh/base/MetaData.hpp> |
| 11 |
#include <stk_mesh/base/Comm.hpp> |
| 12 |
#include <stk_mesh/base/GetEntities.hpp> |
| 13 |
#include <stk_mesh/base/FEMHelpers.hpp> |
| 14 |
#include <stk_mesh/baseImpl/MeshImplUtils.hpp> |
| 15 |
#include <stk_mesh/base/Field.hpp> |
| 16 |
#include <stk_mesh/base/SkinMesh.hpp> |
| 17 |
#include <stk_mesh/base/SkinBoundary.hpp> |
| 18 |
#include <stk_mesh/base/CreateFaces.hpp> |
| 19 |
#include <stk_mesh/base/SkinMeshUtil.hpp> |
| 20 |
#include <stk_mesh/baseImpl/elementGraph/ElemElemGraph.hpp> |
| 21 |
#include <stk_mesh/baseImpl/elementGraph/ElemElemGraphImpl.hpp> |
| 22 |
#include <stk_mesh/baseImpl/elementGraph/ProcessKilledElements.hpp> |
| 23 |
|
| 24 |
#include <stk_util/parallel/Parallel.hpp> |
| 25 |
#include <stk_util/parallel/ParallelVectorConcat.hpp> |
| 26 |
#include <stk_util/parallel/ParallelComm.hpp> |
| 27 |
#include <stk_util/environment/WallTime.hpp> |
| 28 |
#include <stk_util/environment/memory_util.hpp> |
| 29 |
#include <stk_util/parallel/CommSparse.hpp> |
| 30 |
#include <stk_util/util/ReportHandler.hpp> |
| 31 |
|
| 32 |
#include <stk_io/IossBridge.hpp> |
| 33 |
#include <stk_io/StkMeshIoBroker.hpp> // for StkMeshIoBroker |
| 34 |
|
| 35 |
#include <stk_unit_test_utils/ioUtils.hpp> |
| 36 |
#include <stk_unit_test_utils/getOption.h> |
| 37 |
|
| 38 |
#include "stk_unit_test_utils/ElemGraphTestUtils.hpp" |
| 39 |
#include "stk_unit_test_utils/unittestMeshUtils.hpp" |
| 40 |
#include <stk_unit_test_utils/MeshFixture.hpp> |
| 41 |
#include <stk_unit_test_utils/BuildMesh.hpp> |
| 42 |
|
| 43 |
#include "SetupKeyholeMesh.hpp" |
| 44 |
#include <stk_unit_test_utils/stk_mesh_fixtures/QuadFixture.hpp> // for QuadFixture |
| 45 |
#include <stk_unit_test_utils/stk_mesh_fixtures/degenerate_mesh.hpp> |
| 46 |
#include <stk_unit_test_utils/stk_mesh_fixtures/heterogeneous_mesh.hpp> |
| 47 |
#include <stk_unit_test_utils/TextMesh.hpp> |
| 48 |
|
| 49 |
#include "BulkDataElementGraphTester.hpp" |
| 50 |
#include "ElementGraphTester.hpp" |
| 51 |
|
| 52 |
namespace { |
| 53 |
|
| 54 |
using namespace stk::mesh::impl; |
| 55 |
using namespace stk::mesh; |
| 56 |
using stk::unit_test_util::build_mesh; |
| 57 |
|
| 58 |
// Not to be used with ElemElemGraph or ElemElemGraphTester class. |
| 59 |
bool is_valid_graph_element(const impl::ElementGraph &elem_graph, stk::mesh::impl::LocalId elem_id); |
| 60 |
|
| 61 |
// Not to be used with ElemElemGraph or ElemElemGraphTester class. |
| 62 |
int check_connectivity(const impl::ElementGraph &elem_graph, const impl::SidesForElementGraph &via_sides, |
| 63 |
stk::mesh::impl::LocalId element_id1, stk::mesh::impl::LocalId element_id2); |
| 64 |
|
| 65 |
// Not to be used with ElemElemGraph or ElemElemGraphTester class. |
| 66 |
int get_side_from_element1_to_element2(const impl::ElementGraph &elem_graph, |
| 67 |
const impl::SidesForElementGraph &via_sides, |
| 68 |
stk::mesh::impl::LocalId element1_local_id, |
| 69 |
stk::mesh::impl::LocalId other_element_id); |
| 70 |
|
| 71 |
ElemElemGraphTester create_base_1x1x4_elem_graph(stk::ParallelMachine &comm, stk::mesh::BulkData &bulk); |
| 72 |
|
| 73 |
void expect_correct_connected_element_via_side(ElemElemGraphTester& elemElemGraph, stk::mesh::Entity elem, int k, stk::mesh::Entity otherElem, int viaSide) |
| 74 |
{ |
| 75 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(elem, k); |
| 76 |
EXPECT_EQ(viaSide, elem_via_side.side); |
| 77 |
EXPECT_EQ(otherElem, elem_via_side.element); |
| 78 |
} |
| 79 |
|
| 80 |
int get_side_from_element1_to_element2(const stk::mesh::BulkData &bulkData, |
| 81 |
stk::mesh::ElemElemGraph &elem_graph, |
| 82 |
stk::mesh::EntityId element1_local_id, |
| 83 |
stk::mesh::impl::LocalId other_element_id) |
| 84 |
{ |
| 85 |
int side = -1; |
| 86 |
stk::mesh::impl::LocalId elemLocal = elem_graph.get_local_element_id(bulkData.get_entity(stk::topology::ELEM_RANK, element1_local_id)); |
| 87 |
for(const stk::mesh::GraphEdge &graphEdge : elem_graph.get_edges_for_element(elemLocal)) |
| 88 |
if(graphEdge.elem2() == -other_element_id) |
| 89 |
side = graphEdge.side1(); |
| 90 |
return side; |
| 91 |
} |
| 92 |
|
| 93 |
void setup_node_sharing(stk::mesh::BulkData &mesh, const std::vector< std::vector<unsigned> > & shared_nodeIDs_and_procs ) |
| 94 |
{ |
| 95 |
const unsigned p_rank = mesh.parallel_rank(); |
| 96 |
|
| 97 |
for (size_t nodeIdx = 0, end = shared_nodeIDs_and_procs.size(); nodeIdx < end; ++nodeIdx) { |
| 98 |
if (p_rank == shared_nodeIDs_and_procs[nodeIdx][0]) { |
| 99 |
stk::mesh::EntityId nodeID = shared_nodeIDs_and_procs[nodeIdx][1]; |
| 100 |
int sharingProc = shared_nodeIDs_and_procs[nodeIdx][2]; |
| 101 |
stk::mesh::Entity node = mesh.get_entity(stk::topology::NODE_RANK, nodeID); |
| 102 |
mesh.add_node_sharing(node, sharingProc); |
| 103 |
} |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
void test_add_elements_to_pre_existing_graph_and_mesh(stk::mesh::BulkData &bulkData) |
| 108 |
{ |
| 109 |
const int p_size = bulkData.parallel_size(); |
| 110 |
const int p_rank = bulkData.parallel_rank(); |
| 111 |
|
| 112 |
STK_ThrowRequire(2 == p_size); |
| 113 |
|
| 114 |
stk::mesh::MetaData &meta = bulkData.mesh_meta_data(); |
| 115 |
|
| 116 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 117 |
|
| 118 |
stk::io::fill_mesh("generated:1x1x2", bulkData); |
| 119 |
|
| 120 |
std::vector<size_t> counts; |
| 121 |
stk::mesh::count_entities(bulkData.mesh_meta_data().locally_owned_part(), bulkData, counts); |
| 122 |
|
| 123 |
stk::mesh::ElemElemGraph &elem_graph = bulkData.get_face_adjacent_element_graph(); |
| 124 |
|
| 125 |
EXPECT_EQ(1u, elem_graph.size()); |
| 126 |
EXPECT_EQ(1u, counts[stk::topology::ELEM_RANK]); |
| 127 |
|
| 128 |
const std::vector<size_t> numHex{1,1}; |
| 129 |
stk::mesh::EntityIdVector hexNodeIDs[] { |
| 130 |
{ 12, 11, 18, 17, 8, 7, 16, 15 }, |
| 131 |
{ 8, 7, 16, 15, 4, 3, 14, 13 } |
| 132 |
}; |
| 133 |
stk::mesh::EntityIdVector hexElemIDs {3, 4}; |
| 134 |
|
| 135 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 136 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 137 |
{ |
| 138 |
{ 0, 3, 1 }, // proc 0 |
| 139 |
{ 0, 4, 1 }, |
| 140 |
{ 0, 11, 1 }, |
| 141 |
{ 0, 12, 1 }, |
| 142 |
{ 0, 15, 1 }, |
| 143 |
{ 0, 16, 1 }, |
| 144 |
{ 1, 3, 0 }, // proc 1 |
| 145 |
{ 1, 4, 0 }, |
| 146 |
{ 1, 11, 0 }, |
| 147 |
{ 1, 12, 0 }, |
| 148 |
{ 1, 15, 0 }, |
| 149 |
{ 1, 16, 0 }, |
| 150 |
}; |
| 151 |
|
| 152 |
bulkData.modification_begin(); |
| 153 |
stk::mesh::declare_element(bulkData, *hexPart, hexElemIDs[p_rank], hexNodeIDs[p_rank]); |
| 154 |
setup_node_sharing(bulkData, shared_nodeIDs_and_procs ); |
| 155 |
bulkData.modification_end(); |
| 156 |
|
| 157 |
stk::mesh::EntityVector elements_to_add; |
| 158 |
|
| 159 |
if (0 == p_rank) |
| 160 |
{ |
| 161 |
EXPECT_EQ(5, get_side_from_element1_to_element2(bulkData, elem_graph, 1, 2)); |
| 162 |
EXPECT_EQ(2, get_side_from_element1_to_element2(bulkData, elem_graph, 1, 4)); |
| 163 |
EXPECT_EQ(0, get_side_from_element1_to_element2(bulkData, elem_graph, 3, 2)); |
| 164 |
EXPECT_EQ(5, get_side_from_element1_to_element2(bulkData, elem_graph, 3, 4)); |
| 165 |
} |
| 166 |
else |
| 167 |
{ |
| 168 |
EXPECT_EQ(4, get_side_from_element1_to_element2(bulkData, elem_graph, 2, 1)); |
| 169 |
EXPECT_EQ(2, get_side_from_element1_to_element2(bulkData, elem_graph, 2, 3)); |
| 170 |
EXPECT_EQ(0, get_side_from_element1_to_element2(bulkData, elem_graph, 4, 1)); |
| 171 |
EXPECT_EQ(4, get_side_from_element1_to_element2(bulkData, elem_graph, 4, 3)); |
| 172 |
|
| 173 |
} |
| 174 |
EXPECT_EQ(2u, elem_graph.size()); |
| 175 |
EXPECT_EQ(4u, elem_graph.num_edges()); |
| 176 |
EXPECT_EQ(4u, elem_graph.num_parallel_edges()); |
| 177 |
} |
| 178 |
|
| 179 |
void test_delete_elements_from_graph(ElemElemGraphTester &elem_graph, std::vector<stk::mesh::EntityId> &ids_to_delete) |
| 180 |
{ |
| 181 |
std::set<stk::mesh::EntityId> currentElements = {1,2,3,4}; |
| 182 |
stk::mesh::BulkData &bulkData = elem_graph.get_bulk_data(); |
| 183 |
|
| 184 |
stk::mesh::impl::DeletedElementInfoVector elements_to_delete; |
| 185 |
for (size_t i = 0; i < ids_to_delete.size(); ++i) |
| 186 |
{ |
| 187 |
stk::mesh::EntityId id = ids_to_delete[i]; |
| 188 |
currentElements.erase(id); |
| 189 |
stk::mesh::Entity elem = bulkData.get_entity(stk::topology::ELEM_RANK, id); |
| 190 |
if (bulkData.is_valid(elem) && bulkData.bucket(elem).owned()) |
| 191 |
{ |
| 192 |
elements_to_delete.push_back({elem, id, bulkData.bucket(elem).topology()}); |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
bulkData.modification_begin(); |
| 197 |
for (stk::mesh::impl::DeletedElementInfo elem : elements_to_delete) |
| 198 |
{ |
| 199 |
bulkData.destroy_entity(elem.entity); |
| 200 |
stk::mesh::Entity elemCheck = bulkData.get_entity(stk::topology::ELEM_RANK, elem.identifier); |
| 201 |
EXPECT_FALSE(bulkData.is_valid(elemCheck)); |
| 202 |
} |
| 203 |
bulkData.modification_end(); |
| 204 |
|
| 205 |
elem_graph.delete_elements(elements_to_delete); |
| 206 |
|
| 207 |
std::vector<size_t> counts; |
| 208 |
stk::mesh::count_entities(bulkData.mesh_meta_data().locally_owned_part(), bulkData, counts); |
| 209 |
unsigned numLocallyOwnedElems = counts[stk::topology::ELEM_RANK]; |
| 210 |
|
| 211 |
EXPECT_EQ(numLocallyOwnedElems, elem_graph.size()); |
| 212 |
|
| 213 |
unsigned numEdges = 0; |
| 214 |
unsigned numParallelEdges = 0; |
| 215 |
for (stk::mesh::EntityId elem_id : currentElements) |
| 216 |
{ |
| 217 |
stk::mesh::Entity elem = bulkData.get_entity(stk::topology::ELEM_RANK, elem_id); |
| 218 |
|
| 219 |
if (!bulkData.is_valid(elem) || !bulkData.bucket(elem).owned()) |
| 220 |
{ |
| 221 |
continue; |
| 222 |
} |
| 223 |
|
| 224 |
stk::mesh::EntityId leftNeighbor = elem_id - 1; |
| 225 |
if (currentElements.find(leftNeighbor) != currentElements.end()) |
| 226 |
{ |
| 227 |
EXPECT_EQ(4, elem_graph.get_side_from_element1_to_element2(elem_id, leftNeighbor)); |
| 228 |
++numEdges; |
| 229 |
|
| 230 |
stk::mesh::Entity leftElem = bulkData.get_entity(stk::topology::ELEM_RANK, leftNeighbor); |
| 231 |
bool ownedLeftNeighbor = bulkData.is_valid(leftElem) && bulkData.bucket(leftElem).owned(); |
| 232 |
if(!ownedLeftNeighbor) |
| 233 |
{ |
| 234 |
numParallelEdges++; |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
stk::mesh::EntityId rightNeighbor = elem_id + 1; |
| 239 |
if (currentElements.find(rightNeighbor) != currentElements.end()) |
| 240 |
{ |
| 241 |
EXPECT_EQ(5, elem_graph.get_side_from_element1_to_element2(elem_id, rightNeighbor)); |
| 242 |
++numEdges; |
| 243 |
|
| 244 |
stk::mesh::Entity rightElem = bulkData.get_entity(stk::topology::ELEM_RANK, rightNeighbor); |
| 245 |
bool ownedRightNeighbor = bulkData.is_valid(rightElem) && bulkData.bucket(rightElem).owned(); |
| 246 |
if(!ownedRightNeighbor) |
| 247 |
{ |
| 248 |
numParallelEdges++; |
| 249 |
} |
| 250 |
} |
| 251 |
} |
| 252 |
EXPECT_EQ(numEdges, elem_graph.num_edges()); |
| 253 |
EXPECT_EQ(numParallelEdges, elem_graph.num_parallel_edges()); |
| 254 |
} |
| 255 |
|
| 256 |
void test_element_graph_delete_elements_from_graph(stk::mesh::BulkData::AutomaticAuraOption auto_aura_option) |
| 257 |
{ |
| 258 |
MPI_Comm comm = MPI_COMM_WORLD; |
| 259 |
int pSize = stk::parallel_machine_size(comm); |
| 260 |
|
| 261 |
// Test designed for 1, 2, or 4 procs. |
| 262 |
if (pSize > 4) |
| 263 |
{ |
| 264 |
return; |
| 265 |
} |
| 266 |
|
| 267 |
{ |
| 268 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(comm, auto_aura_option); |
| 269 |
|
| 270 |
ElemElemGraphTester elem_graph = create_base_1x1x4_elem_graph(comm, *bulkPtr); |
| 271 |
std::vector<stk::mesh::EntityId> ids_to_delete = {1, 4}; |
| 272 |
test_delete_elements_from_graph(elem_graph, ids_to_delete); |
| 273 |
} |
| 274 |
|
| 275 |
{ |
| 276 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(comm, auto_aura_option); |
| 277 |
|
| 278 |
ElemElemGraphTester elem_graph = create_base_1x1x4_elem_graph(comm, *bulkPtr); |
| 279 |
std::vector<stk::mesh::EntityId> ids_to_delete = {2, 3}; |
| 280 |
test_delete_elements_from_graph(elem_graph, ids_to_delete); |
| 281 |
} |
| 282 |
|
| 283 |
{ |
| 284 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(comm, auto_aura_option); |
| 285 |
|
| 286 |
ElemElemGraphTester elem_graph = create_base_1x1x4_elem_graph(comm, *bulkPtr); |
| 287 |
std::vector<stk::mesh::EntityId> ids_to_delete = {1, 3}; |
| 288 |
test_delete_elements_from_graph(elem_graph, ids_to_delete); |
| 289 |
} |
| 290 |
} |
| 291 |
|
| 292 |
TEST(ElementGraph, delete_elements_from_graph_aura_on) |
| 293 |
{ |
| 294 |
test_element_graph_delete_elements_from_graph(stk::mesh::BulkData::AUTO_AURA); |
| 295 |
} |
| 296 |
|
| 297 |
TEST(ElementGraph, delete_elements_from_graph_aura_off) |
| 298 |
{ |
| 299 |
test_element_graph_delete_elements_from_graph(stk::mesh::BulkData::NO_AUTO_AURA); |
| 300 |
} |
| 301 |
|
| 302 |
TEST(ElementGraph, add_and_delete_elements_from_graph_serial) |
| 303 |
{ |
| 304 |
MPI_Comm comm = MPI_COMM_WORLD; |
| 305 |
|
| 306 |
if(stk::parallel_machine_size(comm) == 1) |
| 307 |
{ |
| 308 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(comm); |
| 309 |
stk::mesh::BulkData& bulkData = *bulkPtr; |
| 310 |
|
| 311 |
ElemElemGraphTester elem_graph(bulkData); |
| 312 |
|
| 313 |
EXPECT_EQ(0u, elem_graph.size()); |
| 314 |
EXPECT_EQ(0u, elem_graph.num_edges()); |
| 315 |
EXPECT_EQ(0u, elem_graph.num_parallel_edges()); |
| 316 |
|
| 317 |
stk::io::fill_mesh("generated:1x1x4", bulkData); |
| 318 |
|
| 319 |
stk::topology hex8 = stk::topology::HEX_8; |
| 320 |
|
| 321 |
std::vector<size_t> counts; |
| 322 |
stk::mesh::count_entities(bulkData.mesh_meta_data().locally_owned_part(), bulkData, counts); |
| 323 |
int numLocallyOwnedElems = counts[stk::topology::ELEM_RANK]; |
| 324 |
EXPECT_EQ(4, numLocallyOwnedElems); |
| 325 |
|
| 326 |
stk::mesh::Entity elem1 = bulkData.get_entity(stk::topology::ELEM_RANK, 1); |
| 327 |
stk::mesh::Entity elem2 = bulkData.get_entity(stk::topology::ELEM_RANK, 2); |
| 328 |
stk::mesh::Entity elem3 = bulkData.get_entity(stk::topology::ELEM_RANK, 3); |
| 329 |
stk::mesh::Entity elem4 = bulkData.get_entity(stk::topology::ELEM_RANK, 4); |
| 330 |
|
| 331 |
stk::mesh::EntityVector elements_to_add; |
| 332 |
elements_to_add.push_back(elem1); |
| 333 |
elements_to_add.push_back(elem2); |
| 334 |
elements_to_add.push_back(elem3); |
| 335 |
elements_to_add.push_back(elem4); |
| 336 |
|
| 337 |
for (unsigned i=0; i<elements_to_add.size(); i++) |
| 338 |
{ |
| 339 |
EXPECT_TRUE(bulkData.is_valid(elements_to_add[i])); |
| 340 |
EXPECT_EQ(0, bulkData.parallel_owner_rank(elements_to_add[i])); |
| 341 |
} |
| 342 |
|
| 343 |
elem_graph.add_elements(elements_to_add); |
| 344 |
|
| 345 |
EXPECT_EQ(4u, elem_graph.size()); |
| 346 |
EXPECT_EQ(6u, elem_graph.num_edges()); |
| 347 |
EXPECT_EQ(0u, elem_graph.num_parallel_edges()); |
| 348 |
|
| 349 |
EXPECT_EQ(5, elem_graph.check_local_connectivity(elem1, elem2)); |
| 350 |
EXPECT_EQ(4, elem_graph.check_local_connectivity(elem2, elem1)); |
| 351 |
EXPECT_EQ(5, elem_graph.check_local_connectivity(elem2, elem3)); |
| 352 |
EXPECT_EQ(4, elem_graph.check_local_connectivity(elem3, elem2)); |
| 353 |
EXPECT_EQ(5, elem_graph.check_local_connectivity(elem3, elem4)); |
| 354 |
EXPECT_EQ(4, elem_graph.check_local_connectivity(elem4, elem3)); |
| 355 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem1, elem3)); |
| 356 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem2, elem4)); |
| 357 |
|
| 358 |
stk::mesh::impl::DeletedElementInfoVector elems_to_delete; |
| 359 |
elems_to_delete.push_back({elem2, 2, hex8}); |
| 360 |
elems_to_delete.push_back({elem3, 3, hex8}); |
| 361 |
|
| 362 |
elem_graph.delete_elements(elems_to_delete); |
| 363 |
|
| 364 |
EXPECT_EQ(2u, elem_graph.size()); |
| 365 |
EXPECT_EQ(0u, elem_graph.num_edges()); |
| 366 |
EXPECT_EQ(0u, elem_graph.num_parallel_edges()); |
| 367 |
|
| 368 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem1, elem2)); |
| 369 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem2, elem1)); |
| 370 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem2, elem3)); |
| 371 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem3, elem2)); |
| 372 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem3, elem4)); |
| 373 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem4, elem3)); |
| 374 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem1, elem3)); |
| 375 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem2, elem4)); |
| 376 |
|
| 377 |
elements_to_add.clear(); |
| 378 |
elements_to_add.push_back(elem2); |
| 379 |
elements_to_add.push_back(elem3); |
| 380 |
|
| 381 |
elem_graph.add_elements(elements_to_add); |
| 382 |
|
| 383 |
EXPECT_EQ(4u, elem_graph.size()); |
| 384 |
EXPECT_EQ(6u, elem_graph.num_edges()); |
| 385 |
EXPECT_EQ(0u, elem_graph.num_parallel_edges()); |
| 386 |
|
| 387 |
EXPECT_EQ(5, elem_graph.check_local_connectivity(elem1, elem2)); |
| 388 |
EXPECT_EQ(4, elem_graph.check_local_connectivity(elem2, elem1)); |
| 389 |
EXPECT_EQ(5, elem_graph.check_local_connectivity(elem2, elem3)); |
| 390 |
EXPECT_EQ(4, elem_graph.check_local_connectivity(elem3, elem2)); |
| 391 |
EXPECT_EQ(5, elem_graph.check_local_connectivity(elem3, elem4)); |
| 392 |
EXPECT_EQ(4, elem_graph.check_local_connectivity(elem4, elem3)); |
| 393 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem1, elem3)); |
| 394 |
EXPECT_EQ(-1, elem_graph.check_local_connectivity(elem2, elem4)); |
| 395 |
|
| 396 |
elems_to_delete.clear(); |
| 397 |
elems_to_delete.push_back({elem4, 4, hex8}); |
| 398 |
elems_to_delete.push_back({elem2, 2, hex8}); |
| 399 |
elems_to_delete.push_back({elem1, 1, hex8}); |
| 400 |
elems_to_delete.push_back({elem3, 3, hex8}); |
| 401 |
|
| 402 |
elem_graph.delete_elements(elems_to_delete); |
| 403 |
|
| 404 |
EXPECT_EQ(0u, elem_graph.size()); |
| 405 |
for(unsigned i=0; i<elem_graph.get_graph().get_num_elements_in_graph(); ++i) |
| 406 |
{ |
| 407 |
EXPECT_EQ(0u, elem_graph.get_graph().get_num_edges_for_element(i)); |
| 408 |
} |
| 409 |
} |
| 410 |
} |
| 411 |
|
| 412 |
TEST(ElementGraph, HexAddShellSerial) |
| 413 |
{ |
| 414 |
// ID.proc |
| 415 |
// |
| 416 |
// 3.0------------7.0 |
| 417 |
// /| /| |
| 418 |
// / | / | |
| 419 |
// / | / | |
| 420 |
// 4.0------------8.0 | |
| 421 |
// | | | | |
| 422 |
// | | 1.0 |2.0| |
| 423 |
// | | | | |
| 424 |
// | 2.0---------|--6.0 |
| 425 |
// | / | / |
| 426 |
// | / | / |
| 427 |
// |/ |/ |
| 428 |
// 1.0------------5.0 |
| 429 |
// ^ |
| 430 |
// | |
| 431 |
// ---- Added single shell element |
| 432 |
|
| 433 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 434 |
int p_size = stk::parallel_machine_size(pm); |
| 435 |
|
| 436 |
if(p_size != 1) { |
| 437 |
return; |
| 438 |
} |
| 439 |
|
| 440 |
const unsigned spatialDim = 3; |
| 441 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 442 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 443 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 444 |
|
| 445 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 446 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 447 |
meta.commit(); |
| 448 |
|
| 449 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 450 |
{ 1, 2, 3, 4, 5, 6, 7, 8 } |
| 451 |
}; |
| 452 |
stk::mesh::EntityId hexElemIDs[] = { 1 }; |
| 453 |
|
| 454 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 455 |
{ 5, 6, 7, 8 } |
| 456 |
}; |
| 457 |
stk::mesh::EntityId shellElemIDs[] = { 2 }; |
| 458 |
|
| 459 |
// Build the base hex mesh |
| 460 |
mesh.modification_begin(); |
| 461 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 462 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 463 |
} |
| 464 |
mesh.modification_end(); |
| 465 |
|
| 466 |
// Initialize the graph based on the existing hex mesh |
| 467 |
ElemElemGraphTester elem_graph(mesh); |
| 468 |
EXPECT_EQ(1u, elem_graph.size()); |
| 469 |
|
| 470 |
// Add a shell |
| 471 |
mesh.modification_begin(); |
| 472 |
stk::mesh::EntityVector added_shells; |
| 473 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 474 |
added_shells.push_back( stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]) ); |
| 475 |
} |
| 476 |
mesh.modification_end(); |
| 477 |
|
| 478 |
elem_graph.add_elements(added_shells); |
| 479 |
|
| 480 |
EXPECT_EQ(2u, elem_graph.size()); |
| 481 |
EXPECT_EQ(0u, elem_graph.num_parallel_edges()); |
| 482 |
|
| 483 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 484 |
const Entity shell2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 485 |
|
| 486 |
{ |
| 487 |
// Connectivity for Hex Element 1 |
| 488 |
EXPECT_EQ(1u, elem_graph.get_num_connected_elems(hex1)); |
| 489 |
impl::ElementViaSidePair elem_via_side = elem_graph.get_connected_element_and_via_side(hex1, 0); |
| 490 |
EXPECT_EQ(5, elem_via_side.side); |
| 491 |
EXPECT_EQ(shell2, elem_via_side.element); |
| 492 |
EXPECT_TRUE(elem_graph.is_connected_elem_locally_owned(hex1, 0)); |
| 493 |
} |
| 494 |
{ |
| 495 |
// Connectivity for Shell Element 2 |
| 496 |
EXPECT_EQ(1u, elem_graph.get_num_connected_elems(shell2)); |
| 497 |
impl::ElementViaSidePair elem_via_side = elem_graph.get_connected_element_and_via_side(shell2, 0); |
| 498 |
EXPECT_EQ(1, elem_via_side.side); |
| 499 |
EXPECT_EQ(hex1, elem_via_side.element); |
| 500 |
EXPECT_TRUE(elem_graph.is_connected_elem_locally_owned(shell2, 0)); |
| 501 |
} |
| 502 |
EXPECT_EQ(0u, elem_graph.num_parallel_edges()); |
| 503 |
} |
| 504 |
|
| 505 |
TEST( ElementGraph, HexDelShellSerial ) |
| 506 |
{ |
| 507 |
// ID.proc |
| 508 |
// |
| 509 |
// 3.0------------7.0 |
| 510 |
// /| /| |
| 511 |
// / | / | |
| 512 |
// / | / | |
| 513 |
// 4.0------------8.0 | |
| 514 |
// | | | | |
| 515 |
// | | 1.0 |2.0| |
| 516 |
// | | | | |
| 517 |
// | 2.0---------|--6.0 |
| 518 |
// | / | / |
| 519 |
// | / | / |
| 520 |
// |/ |/ |
| 521 |
// 1.0------------5.0 |
| 522 |
// ^ |
| 523 |
// | |
| 524 |
// ---- Deleting shell element |
| 525 |
|
| 526 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 527 |
int p_size = stk::parallel_machine_size(pm); |
| 528 |
|
| 529 |
if(p_size > 1) |
| 530 |
{ |
| 531 |
return; |
| 532 |
} |
| 533 |
|
| 534 |
const unsigned spatialDim = 3; |
| 535 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 536 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 537 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 538 |
|
| 539 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 540 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 541 |
meta.commit(); |
| 542 |
|
| 543 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 544 |
{ 1, 2, 3, 4, 5, 6, 7, 8 } |
| 545 |
}; |
| 546 |
stk::mesh::EntityId hexElemIDs[] = { 1 }; |
| 547 |
|
| 548 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 549 |
{ 5, 6, 7, 8 } |
| 550 |
}; |
| 551 |
stk::mesh::EntityId shellElemIDs[] = { 2 }; |
| 552 |
|
| 553 |
mesh.modification_begin(); |
| 554 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 555 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 556 |
} |
| 557 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 558 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 559 |
} |
| 560 |
mesh.modification_end(); |
| 561 |
|
| 562 |
ElemElemGraphTester elemElemGraph(mesh); |
| 563 |
|
| 564 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 565 |
const Entity shell2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 566 |
|
| 567 |
stk::mesh::impl::DeletedElementInfoVector elements_to_delete; |
| 568 |
elements_to_delete.push_back({shell2, 2, mesh.bucket(shell2).topology()}); |
| 569 |
|
| 570 |
elemElemGraph.delete_elements(elements_to_delete); |
| 571 |
|
| 572 |
mesh.modification_begin(); |
| 573 |
mesh.destroy_entity(shell2); |
| 574 |
mesh.modification_end(); |
| 575 |
|
| 576 |
// Connectivity for Hex Element 1 |
| 577 |
EXPECT_EQ(0u, elemElemGraph.get_num_connected_elems(hex1)); |
| 578 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 579 |
|
| 580 |
} |
| 581 |
|
| 582 |
TEST( ElementGraph, HexAddShellHexSerial ) |
| 583 |
{ |
| 584 |
// ID.proc |
| 585 |
// |
| 586 |
// 3.0------------7.0-----------11.0 |
| 587 |
// /| /| /| |
| 588 |
// / | / | / | |
| 589 |
// / | / | / | |
| 590 |
// 4.0------------8.0-----------12.0 | |
| 591 |
// | | | | | | |
| 592 |
// | | 1.0 |3.0| 2.0 | | |
| 593 |
// | | | | | | |
| 594 |
// | 2.0---------|--6.0---------|-10.0 |
| 595 |
// | / | / | / |
| 596 |
// | / | / | / |
| 597 |
// |/ |/ |/ |
| 598 |
// 1.0------------5.0------------9.0 |
| 599 |
// ^ |
| 600 |
// | |
| 601 |
// ---- Added single shell element |
| 602 |
|
| 603 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 604 |
int p_size = stk::parallel_machine_size(pm); |
| 605 |
|
| 606 |
if(p_size > 1) |
| 607 |
{ |
| 608 |
return; |
| 609 |
} |
| 610 |
|
| 611 |
const unsigned spatialDim = 3; |
| 612 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 613 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 614 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 615 |
|
| 616 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 617 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 618 |
meta.commit(); |
| 619 |
|
| 620 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 621 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 622 |
{ 5, 6, 7, 8, 9, 10, 11, 12 } |
| 623 |
}; |
| 624 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2 }; |
| 625 |
|
| 626 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 627 |
{ 5, 6, 7, 8 } |
| 628 |
}; |
| 629 |
stk::mesh::EntityId shellElemIDs[] = { 3 }; |
| 630 |
|
| 631 |
mesh.modification_begin(); |
| 632 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 633 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 634 |
} |
| 635 |
mesh.modification_end(); |
| 636 |
|
| 637 |
ElemElemGraphTester elemElemGraph(mesh); |
| 638 |
|
| 639 |
mesh.modification_begin(); |
| 640 |
stk::mesh::EntityVector added_shells; |
| 641 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 642 |
added_shells.push_back( stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]) ); |
| 643 |
} |
| 644 |
mesh.modification_end(); |
| 645 |
|
| 646 |
elemElemGraph.add_elements(added_shells); |
| 647 |
|
| 648 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 649 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 650 |
const Entity shell3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 651 |
|
| 652 |
{ |
| 653 |
// Connectivity for Hex Element 1 |
| 654 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 655 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex1, 0); |
| 656 |
EXPECT_EQ(5, elem_via_side.side); |
| 657 |
EXPECT_EQ(shell3, elem_via_side.element); |
| 658 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 659 |
} |
| 660 |
{ |
| 661 |
// Connectivity for Hex Element 2 |
| 662 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex2)); |
| 663 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex2, 0); |
| 664 |
EXPECT_EQ(4, elem_via_side.side); |
| 665 |
EXPECT_EQ(shell3, elem_via_side.element); |
| 666 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 667 |
} |
| 668 |
// Connectivity for Shell Element 3 |
| 669 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell3)); |
| 670 |
impl::ElementViaSidePair elem0_via_side = elemElemGraph.get_connected_element_and_via_side(shell3, 0); |
| 671 |
impl::ElementViaSidePair elem1_via_side = elemElemGraph.get_connected_element_and_via_side(shell3, 1); |
| 672 |
EXPECT_EQ(1, elem0_via_side.side); |
| 673 |
EXPECT_EQ(0, elem1_via_side.side); |
| 674 |
EXPECT_EQ(hex1, elem0_via_side.element); |
| 675 |
EXPECT_EQ(hex2, elem1_via_side.element); |
| 676 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(shell3, 0)); |
| 677 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(shell3, 1)); |
| 678 |
|
| 679 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 680 |
} |
| 681 |
|
| 682 |
stk::mesh::Entity get_element_side(stk::mesh::BulkData& bulkData, stk::mesh::Entity element, stk::mesh::ConnectivityOrdinal side_ordinal) |
| 683 |
{ |
| 684 |
stk::mesh::Entity side = stk::mesh::Entity(); |
| 685 |
unsigned ranked_side_ordinal; |
| 686 |
stk::mesh::EntityRank side_rank; |
| 687 |
|
| 688 |
bulkData.bucket(element).topology().ranked_side_ordinal(side_ordinal, ranked_side_ordinal, side_rank); |
| 689 |
|
| 690 |
unsigned elem_num_faces = bulkData.num_connectivity(element, side_rank); |
| 691 |
const stk::mesh::Entity * elem_sides = bulkData.begin(element, side_rank); |
| 692 |
const stk::mesh::ConnectivityOrdinal * elem_ord_it = bulkData.begin_ordinals(element, side_rank); |
| 693 |
for (unsigned i=0 ; i<elem_num_faces ; ++i) |
| 694 |
{ |
| 695 |
if (elem_ord_it[i] == ranked_side_ordinal) |
| 696 |
{ |
| 697 |
side = elem_sides[i]; |
| 698 |
break; |
| 699 |
} |
| 700 |
} |
| 701 |
|
| 702 |
return side; |
| 703 |
} |
| 704 |
|
| 705 |
void test_parallel_graph_info(const stk::mesh::Graph& graph, const ParallelInfoForGraphEdges& parallel_graph, |
| 706 |
LocalId this_element, LocalId other_element, int other_proc, int permutation) |
| 707 |
{ |
| 708 |
bool did_find = false; |
| 709 |
|
| 710 |
for(size_t i=0;i<graph.get_num_elements_in_graph();++i) |
| 711 |
{ |
| 712 |
size_t numConnected = graph.get_num_edges_for_element(i); |
| 713 |
for(size_t j=0;j<numConnected;++j) |
| 714 |
{ |
| 715 |
const stk::mesh::GraphEdge& graphEdge = graph.get_edge_for_element(i, j); |
| 716 |
if(graphEdge.elem2()==-1*other_element && static_cast<LocalId>(i) == this_element) |
| 717 |
{ |
| 718 |
const stk::mesh::impl::ParallelInfo& parallelInfo= parallel_graph.get_parallel_info_for_graph_edge(graphEdge); |
| 719 |
did_find = true; |
| 720 |
EXPECT_EQ(other_proc, parallelInfo.get_proc_rank_of_neighbor()); |
| 721 |
EXPECT_EQ(permutation, parallelInfo.m_permutation); |
| 722 |
} |
| 723 |
} |
| 724 |
} |
| 725 |
ASSERT_TRUE(did_find); |
| 726 |
} |
| 727 |
|
| 728 |
template<class T> |
| 729 |
void print_graph(const std::string &title, int proc_id, T& elem_graph) |
| 730 |
{ |
| 731 |
std::ostringstream os; |
| 732 |
|
| 733 |
os << title << " for processor " << proc_id << std::endl; |
| 734 |
for (size_t i=0;i<elem_graph.size();++i) |
| 735 |
{ |
| 736 |
os << "Element " << i << "::\t"; |
| 737 |
for (size_t j=0;j<elem_graph[i].size();++j) |
| 738 |
{ |
| 739 |
os << elem_graph[i][j] << "\t"; |
| 740 |
} |
| 741 |
os << std::endl; |
| 742 |
} |
| 743 |
std::cerr << os.str(); |
| 744 |
} |
| 745 |
|
| 746 |
//BeginDocExample1 |
| 747 |
|
| 748 |
stk::mesh::EntityVector get_killed_elements(stk::mesh::BulkData& bulkData, const int killValue, const stk::mesh::Part& active) |
| 749 |
{ |
| 750 |
stk::mesh::EntityVector killedElements; |
| 751 |
const stk::mesh::BucketVector& buckets = bulkData.buckets(stk::topology::ELEMENT_RANK); |
| 752 |
for(size_t b = 0; b < buckets.size(); ++b) |
| 753 |
{ |
| 754 |
const stk::mesh::Bucket &bucket = *buckets[b]; |
| 755 |
if(bucket.owned() && bucket.member(active)) |
| 756 |
{ |
| 757 |
for(size_t e = 0; e < bucket.size(); ++e) |
| 758 |
{ |
| 759 |
stk::mesh::Entity entity = bucket[e]; |
| 760 |
bool should_element_be_killed = bulkData.identifier(entity) < static_cast<stk::mesh::EntityId>(killValue); |
| 761 |
if(bulkData.bucket(entity).member(active) && should_element_be_killed == true) |
| 762 |
{ |
| 763 |
killedElements.push_back(bucket[e]); |
| 764 |
} |
| 765 |
} |
| 766 |
} |
| 767 |
} |
| 768 |
return killedElements; |
| 769 |
} |
| 770 |
|
| 771 |
|
| 772 |
TEST(ElementGraph, check_graph_connectivity) |
| 773 |
{ |
| 774 |
// element0 --> element1 --> element2 |
| 775 |
ElementGraph elem_graph = { |
| 776 |
{1}, |
| 777 |
{0,2}, |
| 778 |
{1} |
| 779 |
}; |
| 780 |
|
| 781 |
SidesForElementGraph via_side = { |
| 782 |
{4}, |
| 783 |
{1,5}, |
| 784 |
{3} |
| 785 |
}; |
| 786 |
|
| 787 |
EXPECT_EQ(4, check_connectivity(elem_graph, via_side, 0, 1)); |
| 788 |
EXPECT_EQ(1, check_connectivity(elem_graph, via_side, 1, 0)); |
| 789 |
EXPECT_EQ(5, check_connectivity(elem_graph, via_side, 1, 2)); |
| 790 |
EXPECT_EQ(3, check_connectivity(elem_graph, via_side, 2, 1)); |
| 791 |
|
| 792 |
EXPECT_EQ(-1, check_connectivity(elem_graph, via_side, 0, 2)); |
| 793 |
EXPECT_EQ(-1, check_connectivity(elem_graph, via_side, 2, 0)); |
| 794 |
EXPECT_EQ(-1, check_connectivity(elem_graph, via_side, 3, 0)); |
| 795 |
EXPECT_EQ(-1, check_connectivity(elem_graph, via_side, 0, 3)); |
| 796 |
EXPECT_EQ(-1, check_connectivity(elem_graph, via_side, 0, 0)); |
| 797 |
} |
| 798 |
|
| 799 |
TEST(ElementGraph, create_element_graph_serial) |
| 800 |
{ |
| 801 |
MPI_Comm comm = MPI_COMM_WORLD; |
| 802 |
std::vector<double> wall_times; |
| 803 |
wall_times.reserve(10); |
| 804 |
std::vector<std::string> msgs; |
| 805 |
msgs.reserve(10); |
| 806 |
|
| 807 |
std::vector<size_t> mem_usage; |
| 808 |
|
| 809 |
wall_times.push_back(stk::wall_time()); |
| 810 |
msgs.push_back("program-start"); |
| 811 |
mem_usage.push_back(stk::get_memory_usage_now()); |
| 812 |
|
| 813 |
if(stk::parallel_machine_size(comm) == 1) |
| 814 |
{ |
| 815 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(comm); |
| 816 |
stk::mesh::BulkData& bulkData = *bulkPtr; |
| 817 |
std::ostringstream os; |
| 818 |
|
| 819 |
stk::io::fill_mesh("generated:1x1x4", bulkData); |
| 820 |
|
| 821 |
wall_times.push_back(stk::wall_time()); |
| 822 |
msgs.push_back("after mesh-read"); |
| 823 |
mem_usage.push_back(stk::get_memory_usage_now()); |
| 824 |
|
| 825 |
std::vector<size_t> counts; |
| 826 |
stk::mesh::count_entities(bulkData.mesh_meta_data().locally_owned_part(), bulkData, counts); |
| 827 |
int numElems = counts[stk::topology::ELEM_RANK]; |
| 828 |
EXPECT_EQ(4, numElems); |
| 829 |
|
| 830 |
ElemElemGraphTester elemElemGraph(bulkData); |
| 831 |
|
| 832 |
size_t expectedNumElems = counts[stk::topology::ELEM_RANK]; |
| 833 |
ASSERT_EQ(expectedNumElems, elemElemGraph.get_graph_size()); |
| 834 |
|
| 835 |
wall_times.push_back(stk::wall_time()); |
| 836 |
msgs.push_back("after ElemElemGraphTester constructor"); |
| 837 |
mem_usage.push_back(stk::get_memory_usage_now()); |
| 838 |
|
| 839 |
int left_side_id = 4; |
| 840 |
int right_side_id = 5; |
| 841 |
|
| 842 |
for(size_t i=0; i<elemElemGraph.get_graph().get_num_elements_in_graph(); ++i) |
| 843 |
{ |
| 844 |
size_t numConnected = elemElemGraph.get_graph().get_num_edges_for_element(i); |
| 845 |
if (i == 0) |
| 846 |
{ |
| 847 |
ASSERT_EQ(1u, numConnected); |
| 848 |
const stk::mesh::GraphEdge & graphEdge = elemElemGraph.get_graph().get_edge_for_element(i, 0); |
| 849 |
EXPECT_EQ(1, graphEdge.elem2()); |
| 850 |
EXPECT_EQ(right_side_id, graphEdge.side1()); |
| 851 |
} |
| 852 |
else if (i == elemElemGraph.get_graph().get_num_elements_in_graph() - 1) |
| 853 |
{ |
| 854 |
LocalId second_to_last_element_index = elemElemGraph.get_graph().get_num_elements_in_graph() - 2; |
| 855 |
ASSERT_EQ(1u, numConnected); |
| 856 |
const stk::mesh::GraphEdge & graphEdge = elemElemGraph.get_graph().get_edge_for_element(i, 0); |
| 857 |
EXPECT_EQ(second_to_last_element_index, graphEdge.elem2()); |
| 858 |
EXPECT_EQ(left_side_id, graphEdge.side1()); |
| 859 |
} |
| 860 |
else |
| 861 |
{ |
| 862 |
ASSERT_EQ(2u, numConnected); |
| 863 |
LocalId element_to_the_left = i-1; |
| 864 |
LocalId element_to_the_right = i+1; |
| 865 |
const stk::mesh::GraphEdge & graphEdge0 = elemElemGraph.get_graph().get_edge_for_element(i, 0); |
| 866 |
const stk::mesh::GraphEdge & graphEdge1 = elemElemGraph.get_graph().get_edge_for_element(i, 1); |
| 867 |
EXPECT_EQ(element_to_the_left, graphEdge0.elem2()); |
| 868 |
EXPECT_EQ(element_to_the_right, graphEdge1.elem2()); |
| 869 |
EXPECT_EQ(left_side_id, graphEdge0.side1()); |
| 870 |
EXPECT_EQ(right_side_id, graphEdge1.side1()); |
| 871 |
} |
| 872 |
} |
| 873 |
|
| 874 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 875 |
|
| 876 |
if (stk::parallel_machine_rank(comm) == 0) |
| 877 |
{ |
| 878 |
for(size_t i=0;i<wall_times.size();++i) |
| 879 |
{ |
| 880 |
std::cerr << "Wall time " << msgs[i] << ":\t" << wall_times[i] - wall_times[0] << std::endl; |
| 881 |
} |
| 882 |
|
| 883 |
for(size_t i=0;i<mem_usage.size();++i) |
| 884 |
{ |
| 885 |
std::cerr << "Memory usage " << msgs[i] << ":\t" << mem_usage[i] - mem_usage[0] << std::endl; |
| 886 |
} |
| 887 |
} |
| 888 |
} |
| 889 |
} |
| 890 |
|
| 891 |
TEST(ElementGraph, create_element_graph_parallel) |
| 892 |
{ |
| 893 |
MPI_Comm comm = MPI_COMM_WORLD; |
| 894 |
std::vector<double> wall_times; |
| 895 |
wall_times.reserve(10); |
| 896 |
std::vector<std::string> msgs; |
| 897 |
msgs.reserve(10); |
| 898 |
|
| 899 |
std::vector<size_t> mem_usage; |
| 900 |
|
| 901 |
wall_times.push_back(stk::wall_time()); |
| 902 |
msgs.push_back("program-start"); |
| 903 |
mem_usage.push_back(stk::get_memory_usage_now()); |
| 904 |
|
| 905 |
if(stk::parallel_machine_size(comm) == 2) |
| 906 |
{ |
| 907 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(comm); |
| 908 |
stk::mesh::BulkData& bulkData = *bulkPtr; |
| 909 |
|
| 910 |
stk::io::fill_mesh("generated:1x1x4", bulkData); |
| 911 |
|
| 912 |
std::vector<size_t> counts; |
| 913 |
stk::mesh::count_entities(bulkData.mesh_meta_data().locally_owned_part(), bulkData, counts); |
| 914 |
int numLocallyOwnedElems = counts[stk::topology::ELEM_RANK]; |
| 915 |
EXPECT_EQ(2, numLocallyOwnedElems); |
| 916 |
|
| 917 |
ElemElemGraphTester elemElemGraph(bulkData); |
| 918 |
|
| 919 |
size_t expectedNumElems = counts[stk::topology::ELEM_RANK]; |
| 920 |
ASSERT_EQ(expectedNumElems, elemElemGraph.get_graph_size()); |
| 921 |
|
| 922 |
wall_times.push_back(stk::wall_time()); |
| 923 |
msgs.push_back("after ElemElemGraphTester constructor"); |
| 924 |
mem_usage.push_back(stk::get_memory_usage_now()); |
| 925 |
|
| 926 |
LocalId element_to_test_local_id = std::numeric_limits<LocalId>::max(); |
| 927 |
int side_id = -1; |
| 928 |
int left_side_id = 4; |
| 929 |
int right_side_id = 5; |
| 930 |
|
| 931 |
EXPECT_EQ(2u, elemElemGraph.get_graph().get_num_elements_in_graph()); |
| 932 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 933 |
|
| 934 |
if (stk::parallel_machine_rank(comm) == 0) |
| 935 |
{ |
| 936 |
element_to_test_local_id = 1; |
| 937 |
side_id = right_side_id; |
| 938 |
} |
| 939 |
else |
| 940 |
{ |
| 941 |
element_to_test_local_id = 0; |
| 942 |
side_id = left_side_id; |
| 943 |
} |
| 944 |
|
| 945 |
for(size_t i=0;i<elemElemGraph.get_graph().get_num_elements_in_graph();++i) |
| 946 |
{ |
| 947 |
size_t numConnectedElements = elemElemGraph.get_graph().get_num_edges_for_element(i); |
| 948 |
if (static_cast<LocalId>(i) == element_to_test_local_id) |
| 949 |
{ |
| 950 |
// Element on parallel boundary |
| 951 |
ASSERT_EQ(2u, numConnectedElements); |
| 952 |
const stk::mesh::GraphEdge & graphEdge = elemElemGraph.get_graph().get_edge_for_element(i, 1); |
| 953 |
ASSERT_GE(-1, graphEdge.elem2()); |
| 954 |
ASSERT_EQ(side_id, graphEdge.side1()); |
| 955 |
} |
| 956 |
else |
| 957 |
{ |
| 958 |
EXPECT_EQ(1u, numConnectedElements); |
| 959 |
} |
| 960 |
} |
| 961 |
|
| 962 |
if (stk::parallel_machine_rank(comm) == 0) |
| 963 |
{ |
| 964 |
for(size_t i=0;i<wall_times.size();++i) |
| 965 |
{ |
| 966 |
std::cerr << "Wall time " << msgs[i] << ":\t" << wall_times[i] - wall_times[0] << std::endl; |
| 967 |
} |
| 968 |
|
| 969 |
for(size_t i=0;i<mem_usage.size();++i) |
| 970 |
{ |
| 971 |
std::cerr << "Memory usage " << msgs[i] << ":\t" << mem_usage[i] - mem_usage[0] << std::endl; |
| 972 |
} |
| 973 |
} |
| 974 |
} |
| 975 |
} |
| 976 |
|
| 977 |
TEST(ElementSide, get_or_create_element_side_with_permutation) |
| 978 |
{ |
| 979 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 980 |
if(stk::parallel_machine_size(comm) == 1) |
| 981 |
{ |
| 982 |
unsigned spatialDim = 3; |
| 983 |
stk::mesh::MetaData meta(spatialDim); |
| 984 |
stk::mesh::Part& new_faces_part = meta.declare_part_with_topology("surface_5", stk::topology::QUAD_4); |
| 985 |
stk::mesh::PartVector face_parts {&new_faces_part}; |
| 986 |
stk::io::put_io_part_attribute(new_faces_part); |
| 987 |
BulkDataElementGraphTester bulkData(meta, comm); |
| 988 |
|
| 989 |
stk::io::fill_mesh("generated:1x1x3", bulkData); |
| 990 |
|
| 991 |
//////////////// Make first side |
| 992 |
|
| 993 |
bulkData.modification_begin(); |
| 994 |
|
| 995 |
//get_or_create_element_side_with_permutation(bulkData, element); |
| 996 |
stk::topology elemTopo = stk::topology::HEX_8; |
| 997 |
stk::mesh::Entity element1 = bulkData.get_entity(stk::topology::ELEM_RANK, 1); |
| 998 |
EXPECT_EQ(elemTopo, bulkData.bucket(element1).topology()); |
| 999 |
stk::mesh::EntityId side_global_id = 11; |
| 1000 |
stk::mesh::Permutation side_permutation = static_cast<stk::mesh::Permutation>(4); |
| 1001 |
stk::mesh::ConnectivityOrdinal side_ordinal = static_cast<stk::mesh::ConnectivityOrdinal>(1); |
| 1002 |
stk::mesh::EntityRank side_rank = elemTopo.side_rank(side_ordinal); |
| 1003 |
|
| 1004 |
EXPECT_FALSE(impl::is_id_already_in_use_locally(bulkData, side_rank, side_global_id)); |
| 1005 |
EXPECT_FALSE(impl::does_side_exist_with_different_permutation(bulkData, element1, side_ordinal, side_permutation)); |
| 1006 |
EXPECT_FALSE(impl::does_element_side_exist(bulkData, element1, side_ordinal)); |
| 1007 |
|
| 1008 |
impl::connect_side_to_element(bulkData, element1, side_global_id, side_ordinal, side_permutation, face_parts); |
| 1009 |
|
| 1010 |
bulkData.modification_end(); |
| 1011 |
|
| 1012 |
stk::mesh::Entity side1 = get_element_side(bulkData, element1, side_ordinal); |
| 1013 |
EXPECT_TRUE(bulkData.is_valid(side1)); |
| 1014 |
|
| 1015 |
EXPECT_TRUE(impl::is_id_already_in_use_locally(bulkData, side_rank, side_global_id)); |
| 1016 |
|
| 1017 |
stk::mesh::Permutation side_permutation1 = static_cast<stk::mesh::Permutation>(0); |
| 1018 |
EXPECT_TRUE(impl::does_side_exist_with_different_permutation(bulkData, element1, side_ordinal, side_permutation1)); |
| 1019 |
|
| 1020 |
size_t num_sides = stk::mesh::count_selected_entities(new_faces_part, bulkData.buckets(side_rank)); |
| 1021 |
EXPECT_EQ(1u, num_sides); |
| 1022 |
} |
| 1023 |
} |
| 1024 |
|
| 1025 |
TEST(ElementSide, get_or_create_element_side_with_permutation_for_element_with_mixed_side_ranks) |
| 1026 |
{ |
| 1027 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 1028 |
if(stk::parallel_machine_size(comm) == 1) |
| 1029 |
{ |
| 1030 |
unsigned spatialDim = 3; |
| 1031 |
stk::mesh::MetaData meta(spatialDim); |
| 1032 |
stk::mesh::Part& new_sides_part = meta.declare_part_with_topology("surface_5", stk::topology::LINE_2); |
| 1033 |
stk::mesh::PartVector side_parts {&new_sides_part}; |
| 1034 |
stk::io::put_io_part_attribute(new_sides_part); |
| 1035 |
BulkDataElementGraphTester bulkData(meta, comm); |
| 1036 |
|
| 1037 |
stk::io::fill_mesh("textmesh:0,1,SHELL_QUAD_4, 1,2,3,4, block_1", bulkData); |
| 1038 |
|
| 1039 |
//////////////// Make first side |
| 1040 |
|
| 1041 |
bulkData.modification_begin(); |
| 1042 |
|
| 1043 |
//get_or_create_element_side_with_permutation(bulkData, element); |
| 1044 |
stk::topology elemTopo = stk::topology::SHELL_QUAD_4; |
| 1045 |
stk::mesh::Entity element1 = bulkData.get_entity(stk::topology::ELEM_RANK, 1); |
| 1046 |
EXPECT_EQ(elemTopo, bulkData.bucket(element1).topology()); |
| 1047 |
stk::mesh::EntityId side_global_id = 11; |
| 1048 |
stk::mesh::Permutation side_permutation = static_cast<stk::mesh::Permutation>(1); |
| 1049 |
stk::mesh::ConnectivityOrdinal side_ordinal = static_cast<stk::mesh::ConnectivityOrdinal>(2); |
| 1050 |
stk::mesh::EntityRank side_rank = elemTopo.side_rank(side_ordinal); |
| 1051 |
|
| 1052 |
EXPECT_FALSE(impl::is_id_already_in_use_locally(bulkData, side_rank, side_global_id)); |
| 1053 |
EXPECT_FALSE(impl::does_side_exist_with_different_permutation(bulkData, element1, side_ordinal, side_permutation)); |
| 1054 |
EXPECT_FALSE(impl::does_element_side_exist(bulkData, element1, side_ordinal)); |
| 1055 |
|
| 1056 |
impl::connect_side_to_element(bulkData, element1, side_global_id, side_ordinal, side_permutation, side_parts); |
| 1057 |
|
| 1058 |
bulkData.modification_end(); |
| 1059 |
|
| 1060 |
stk::mesh::Entity side1 = get_element_side(bulkData, element1, side_ordinal); |
| 1061 |
EXPECT_TRUE(bulkData.is_valid(side1)); |
| 1062 |
|
| 1063 |
EXPECT_TRUE(impl::is_id_already_in_use_locally(bulkData, side_rank, side_global_id)); |
| 1064 |
|
| 1065 |
stk::mesh::Permutation side_permutation1 = static_cast<stk::mesh::Permutation>(0); |
| 1066 |
EXPECT_TRUE(impl::does_side_exist_with_different_permutation(bulkData, element1, side_ordinal, side_permutation1)); |
| 1067 |
|
| 1068 |
size_t num_sides = stk::mesh::count_selected_entities(new_sides_part, bulkData.buckets(side_rank)); |
| 1069 |
EXPECT_EQ(1u, num_sides); |
| 1070 |
} |
| 1071 |
} |
| 1072 |
|
| 1073 |
TEST(ElementGraph, test_parallel_graph_info_data_structure) |
| 1074 |
{ |
| 1075 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) == 1) |
| 1076 |
{ |
| 1077 |
const int other_side_ord = 2; |
| 1078 |
|
| 1079 |
stk::mesh::Graph graph; |
| 1080 |
graph.set_num_local_elements(2); |
| 1081 |
stk::mesh::GraphEdge graphEdge(1, 5, -3, other_side_ord); |
| 1082 |
std::vector<stk::mesh::GraphEdge> edges = |
| 1083 |
{ stk::mesh::GraphEdge(0, 4, 1, 1), |
| 1084 |
stk::mesh::GraphEdge(1, 1, 0, 4), |
| 1085 |
graphEdge }; |
| 1086 |
graph.add_sorted_edges(edges); |
| 1087 |
|
| 1088 |
stk::mesh::ParallelInfoForGraphEdges parallel_graph(stk::parallel_machine_rank(MPI_COMM_WORLD)); |
| 1089 |
int other_proc = 1; |
| 1090 |
LocalId local_element = 1; |
| 1091 |
LocalId other_element = 3; |
| 1092 |
int permutation = 0; |
| 1093 |
|
| 1094 |
parallel_graph.insert_parallel_info_for_graph_edge(graphEdge, stk::mesh::impl::ParallelInfo(other_proc, permutation, |
| 1095 |
stk::topology::INVALID_TOPOLOGY)); |
| 1096 |
|
| 1097 |
size_t num_elems_this_proc = graph.get_num_elements_in_graph(); |
| 1098 |
EXPECT_EQ(2u, num_elems_this_proc); |
| 1099 |
|
| 1100 |
test_parallel_graph_info(graph, parallel_graph, local_element, other_element, other_proc, permutation); |
| 1101 |
} |
| 1102 |
} |
| 1103 |
|
| 1104 |
TEST(ElementGraph, test_parallel_graph_info_with_parallel_element_graph) |
| 1105 |
{ |
| 1106 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 1107 |
|
| 1108 |
if(stk::parallel_machine_size(comm) == 2) |
| 1109 |
{ |
| 1110 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(comm); |
| 1111 |
stk::mesh::BulkData& bulkData = *bulkPtr; |
| 1112 |
|
| 1113 |
stk::io::fill_mesh("generated:1x1x4", bulkData); |
| 1114 |
|
| 1115 |
std::vector<size_t> counts; |
| 1116 |
stk::mesh::count_entities(bulkData.mesh_meta_data().locally_owned_part(), bulkData, counts); |
| 1117 |
size_t numLocallyOwnedElems = counts[stk::topology::ELEM_RANK]; |
| 1118 |
|
| 1119 |
ElemElemGraphTester elemElemGraph(bulkData); |
| 1120 |
|
| 1121 |
ASSERT_EQ(numLocallyOwnedElems, elemElemGraph.get_graph_size()); |
| 1122 |
|
| 1123 |
ParallelInfoForGraphEdges & parallel_graph = elemElemGraph.get_parallel_graph(); |
| 1124 |
|
| 1125 |
if(stk::parallel_machine_rank(comm)==0) |
| 1126 |
{ |
| 1127 |
LocalId local_element = 1; |
| 1128 |
LocalId other_element = 3; |
| 1129 |
int other_proc = 1; |
| 1130 |
int permutation = 4; |
| 1131 |
|
| 1132 |
test_parallel_graph_info(elemElemGraph.get_graph(), parallel_graph, local_element, other_element, other_proc, permutation); |
| 1133 |
} |
| 1134 |
else |
| 1135 |
{ |
| 1136 |
LocalId local_element = 0; |
| 1137 |
LocalId other_element = 2; |
| 1138 |
int other_proc = 0; |
| 1139 |
int permutation = 4; |
| 1140 |
|
| 1141 |
test_parallel_graph_info(elemElemGraph.get_graph(), parallel_graph, local_element, other_element, other_proc, permutation); |
| 1142 |
} |
| 1143 |
|
| 1144 |
EXPECT_EQ(3u, elemElemGraph.num_edges()); |
| 1145 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 1146 |
} |
| 1147 |
} |
| 1148 |
|
| 1149 |
TEST(ElementGraph, create_faces_using_element_graph_parallel) |
| 1150 |
{ |
| 1151 |
MPI_Comm comm = MPI_COMM_WORLD; |
| 1152 |
std::vector<double> wall_times; |
| 1153 |
wall_times.reserve(10); |
| 1154 |
std::vector<std::string> msgs; |
| 1155 |
msgs.reserve(10); |
| 1156 |
|
| 1157 |
std::vector<size_t> mem_usage; |
| 1158 |
|
| 1159 |
wall_times.push_back(stk::wall_time()); |
| 1160 |
msgs.push_back("program-start"); |
| 1161 |
mem_usage.push_back(stk::get_memory_usage_now()); |
| 1162 |
|
| 1163 |
if(stk::parallel_machine_size(comm) <= 2) |
| 1164 |
{ |
| 1165 |
unsigned spatialDim = 3; |
| 1166 |
stk::mesh::MetaData meta(spatialDim); |
| 1167 |
stk::mesh::Part& new_faces_part = meta.declare_part_with_topology("surface_5", stk::topology::QUAD_4); |
| 1168 |
stk::io::put_io_part_attribute(new_faces_part); |
| 1169 |
BulkDataElementGraphTester bulkData(meta, comm); |
| 1170 |
|
| 1171 |
stk::io::fill_mesh("generated:1x1x4", bulkData); |
| 1172 |
|
| 1173 |
wall_times.push_back(stk::wall_time()); |
| 1174 |
msgs.push_back("after mesh-read"); |
| 1175 |
mem_usage.push_back(stk::get_memory_usage_now()); |
| 1176 |
|
| 1177 |
const bool connectFacesToEdges = false; |
| 1178 |
stk::mesh::create_all_sides(bulkData, meta.universal_part(), {&new_faces_part}, connectFacesToEdges); |
| 1179 |
|
| 1180 |
const stk::mesh::BucketVector& sharedNodeBuckets = bulkData.get_buckets(stk::topology::NODE_RANK, meta.globally_shared_part()); |
| 1181 |
for(size_t bucket_index=0; bucket_index<sharedNodeBuckets.size(); ++bucket_index) |
| 1182 |
{ |
| 1183 |
const stk::mesh::Bucket& bucket = *sharedNodeBuckets[bucket_index]; |
| 1184 |
EXPECT_TRUE(bucket.member(new_faces_part)); |
| 1185 |
} |
| 1186 |
|
| 1187 |
wall_times.push_back(stk::wall_time()); |
| 1188 |
msgs.push_back("after create-faces"); |
| 1189 |
mem_usage.push_back(stk::get_memory_usage_now()); |
| 1190 |
|
| 1191 |
std::vector<size_t> entity_counts; |
| 1192 |
stk::mesh::comm_mesh_counts(bulkData, entity_counts); |
| 1193 |
stk::mesh::EntityRank side_rank = meta.side_rank(); |
| 1194 |
unsigned num_faces = entity_counts[side_rank]; |
| 1195 |
EXPECT_EQ(21u, num_faces); |
| 1196 |
|
| 1197 |
if (stk::parallel_machine_rank(comm) == 0) |
| 1198 |
{ |
| 1199 |
for(size_t i=0;i<wall_times.size();++i) |
| 1200 |
{ |
| 1201 |
std::cerr << "Wall time " << msgs[i] << ":\t" << wall_times[i] - wall_times[0] << std::endl; |
| 1202 |
} |
| 1203 |
|
| 1204 |
for(size_t i=0;i<mem_usage.size();++i) |
| 1205 |
{ |
| 1206 |
std::cerr << "Memory usage " << msgs[i] << ":\t" << mem_usage[i] - mem_usage[0] << std::endl; |
| 1207 |
} |
| 1208 |
} |
| 1209 |
} |
| 1210 |
} |
| 1211 |
|
| 1212 |
TEST(ElementGraph, create_faces_using_element_graph_parallel_block_membership) |
| 1213 |
{ |
| 1214 |
MPI_Comm comm = MPI_COMM_WORLD; |
| 1215 |
std::vector<double> wall_times; |
| 1216 |
wall_times.reserve(10); |
| 1217 |
std::vector<std::string> msgs; |
| 1218 |
msgs.reserve(10); |
| 1219 |
|
| 1220 |
std::vector<size_t> mem_usage; |
| 1221 |
|
| 1222 |
wall_times.push_back(stk::wall_time()); |
| 1223 |
msgs.push_back("program-start"); |
| 1224 |
mem_usage.push_back(stk::get_memory_usage_now()); |
| 1225 |
|
| 1226 |
if(stk::parallel_machine_size(comm) <= 2) |
| 1227 |
{ |
| 1228 |
unsigned spatialDim = 3; |
| 1229 |
stk::mesh::MetaData meta(spatialDim); |
| 1230 |
stk::mesh::Part& new_faces_part = meta.declare_part_with_topology("surface_5", stk::topology::QUAD_4); |
| 1231 |
|
| 1232 |
stk::mesh::Part& block_2 = meta.declare_part_with_topology("block_2", stk::topology::HEX_8); |
| 1233 |
EXPECT_EQ(stk::topology::ELEM_RANK, block_2.primary_entity_rank()); |
| 1234 |
|
| 1235 |
stk::io::put_io_part_attribute(new_faces_part); |
| 1236 |
BulkDataElementGraphTester bulkData(meta, comm); |
| 1237 |
|
| 1238 |
stk::io::fill_mesh("generated:1x1x4", bulkData); |
| 1239 |
|
| 1240 |
wall_times.push_back(stk::wall_time()); |
| 1241 |
msgs.push_back("after mesh-read"); |
| 1242 |
mem_usage.push_back(stk::get_memory_usage_now()); |
| 1243 |
|
| 1244 |
stk::mesh::Part& block_1 = *meta.get_part("block_1"); |
| 1245 |
|
| 1246 |
bulkData.modification_begin(); |
| 1247 |
|
| 1248 |
if (bulkData.parallel_rank() == 1) |
| 1249 |
{ |
| 1250 |
//Move elem 3 from block_1 to block_2 so that the boundary between block_1 and block_2 |
| 1251 |
//will coincide with the proc boundary, and the shared face between elems 2 & 3 |
| 1252 |
//should have both block_1 and block_2. |
| 1253 |
stk::mesh::Entity elem3 = bulkData.get_entity(stk::topology::ELEM_RANK, 3); |
| 1254 |
ASSERT_TRUE(bulkData.is_valid(elem3)); |
| 1255 |
stk::mesh::PartVector add_parts(1, &block_2); |
| 1256 |
stk::mesh::PartVector rem_parts(1, &block_1); |
| 1257 |
bulkData.change_entity_parts(elem3, add_parts, rem_parts); |
| 1258 |
} |
| 1259 |
|
| 1260 |
bulkData.modification_end(); |
| 1261 |
|
| 1262 |
const bool connectFacesToEdges = false; |
| 1263 |
stk::mesh::create_all_sides(bulkData, meta.universal_part(), {&new_faces_part}, connectFacesToEdges); |
| 1264 |
|
| 1265 |
wall_times.push_back(stk::wall_time()); |
| 1266 |
msgs.push_back("after create-faces"); |
| 1267 |
mem_usage.push_back(stk::get_memory_usage_now()); |
| 1268 |
|
| 1269 |
std::vector<size_t> entity_counts; |
| 1270 |
stk::mesh::comm_mesh_counts(bulkData, entity_counts); |
| 1271 |
stk::mesh::EntityRank side_rank = bulkData.mesh_meta_data().side_rank(); |
| 1272 |
unsigned num_faces = entity_counts[side_rank]; |
| 1273 |
EXPECT_EQ(21u, num_faces); |
| 1274 |
|
| 1275 |
const stk::mesh::BucketVector& sharedFaceBuckets = bulkData.get_buckets(stk::topology::FACE_RANK, meta.globally_shared_part()); |
| 1276 |
if (bulkData.parallel_size() == 2) |
| 1277 |
{ |
| 1278 |
ASSERT_EQ(1u, sharedFaceBuckets.size()); |
| 1279 |
|
| 1280 |
const stk::mesh::Bucket& bucket = *sharedFaceBuckets[0]; |
| 1281 |
ASSERT_EQ(1u, bucket.size()); |
| 1282 |
EXPECT_TRUE(bucket.member(block_2)); |
| 1283 |
EXPECT_TRUE(bucket.member(block_1)); |
| 1284 |
} |
| 1285 |
|
| 1286 |
if (stk::parallel_machine_rank(comm) == 0) |
| 1287 |
{ |
| 1288 |
for(size_t i=0;i<wall_times.size();++i) |
| 1289 |
{ |
| 1290 |
std::cerr << "Wall time " << msgs[i] << ":\t" << wall_times[i] - wall_times[0] << std::endl; |
| 1291 |
} |
| 1292 |
|
| 1293 |
for(size_t i=0;i<mem_usage.size();++i) |
| 1294 |
{ |
| 1295 |
std::cerr << "Memory usage " << msgs[i] << ":\t" << mem_usage[i] - mem_usage[0] << std::endl; |
| 1296 |
} |
| 1297 |
} |
| 1298 |
} |
| 1299 |
} |
| 1300 |
|
| 1301 |
TEST(ElementGraph, compare_performance_create_faces) |
| 1302 |
{ |
| 1303 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 1304 |
|
| 1305 |
int xdim = stk::unit_test_util::get_command_line_option("--xdim", 3); |
| 1306 |
int ydim = xdim; |
| 1307 |
int zdim = xdim * stk::parallel_machine_size(comm); |
| 1308 |
|
| 1309 |
std::string filename = stk::unit_test_util::get_name_of_generated_mesh(xdim, ydim, zdim, "|nodeset:zZ"); |
| 1310 |
|
| 1311 |
{ |
| 1312 |
unsigned spatialDim = 3; |
| 1313 |
stk::mesh::MetaData meta(spatialDim); |
| 1314 |
stk::mesh::Part& faces_part = meta.declare_part_with_topology("surface_5", stk::topology::QUAD_4); |
| 1315 |
stk::io::put_io_part_attribute(faces_part); |
| 1316 |
BulkDataElementGraphTester bulkData(meta, comm); |
| 1317 |
|
| 1318 |
stk::io::fill_mesh(filename, bulkData); |
| 1319 |
|
| 1320 |
{ |
| 1321 |
double wall_time_start = stk::wall_time(); |
| 1322 |
|
| 1323 |
stk::mesh::PartVector parts(1, &faces_part); |
| 1324 |
stk::mesh::create_faces(bulkData); |
| 1325 |
|
| 1326 |
double elapsed_time = stk::wall_time() - wall_time_start; |
| 1327 |
|
| 1328 |
if (stk::parallel_machine_rank(comm) == 0) |
| 1329 |
{ |
| 1330 |
std::cerr << "Create faces without graph time: " << elapsed_time << std::endl; |
| 1331 |
} |
| 1332 |
} |
| 1333 |
} |
| 1334 |
|
| 1335 |
{ |
| 1336 |
unsigned spatialDim = 3; |
| 1337 |
stk::mesh::MetaData meta(spatialDim); |
| 1338 |
bool force_no_induce = true; |
| 1339 |
stk::mesh::Part& faces_part = meta.declare_part_with_topology("surface_5", stk::topology::QUAD_4, force_no_induce); |
| 1340 |
stk::io::put_io_part_attribute(faces_part); |
| 1341 |
const bool connectFacesToEdges = false; |
| 1342 |
BulkDataElementGraphTester bulkData(meta, comm); |
| 1343 |
|
| 1344 |
stk::io::fill_mesh(filename, bulkData); |
| 1345 |
|
| 1346 |
{ |
| 1347 |
double wall_time_start = stk::wall_time(); |
| 1348 |
|
| 1349 |
stk::mesh::create_all_sides(bulkData, meta.universal_part(), {&faces_part}, connectFacesToEdges); |
| 1350 |
|
| 1351 |
double elapsed_time = stk::wall_time() - wall_time_start; |
| 1352 |
|
| 1353 |
std::vector<size_t> counts; |
| 1354 |
stk::mesh::comm_mesh_counts(bulkData, counts); |
| 1355 |
|
| 1356 |
if (stk::parallel_machine_rank(comm) == 0) |
| 1357 |
{ |
| 1358 |
std::cerr << "Total time for creating graph and faces: " << elapsed_time << std::endl; |
| 1359 |
std::cerr << "Total # of elements: " << counts[stk::topology::ELEM_RANK] << std::endl; |
| 1360 |
} |
| 1361 |
} |
| 1362 |
} |
| 1363 |
} |
| 1364 |
|
| 1365 |
TEST(ElementGraph, make_items_inactive) |
| 1366 |
{ |
| 1367 |
stk::ParallelMachine comm = stk::parallel_machine_world(); |
| 1368 |
const int nProc = stk::parallel_machine_size(comm); |
| 1369 |
|
| 1370 |
if(nProc > 2) { GTEST_SKIP(); } |
| 1371 |
|
| 1372 |
unsigned spatialDim = 3; |
| 1373 |
|
| 1374 |
stk::mesh::MetaData meta(spatialDim); |
| 1375 |
stk::mesh::Part& faces_part = meta.declare_part_with_topology("surface_5", stk::topology::QUAD_4); |
| 1376 |
stk::mesh::PartVector boundary_mesh_parts { &faces_part }; |
| 1377 |
stk::io::put_io_part_attribute(faces_part); |
| 1378 |
ElemGraphTestUtils::ElementDeathBulkDataTester bulkData(meta, comm, stk::mesh::BulkData::AUTO_AURA); |
| 1379 |
|
| 1380 |
stk::mesh::Part& active = meta.declare_part("active"); // can't specify rank, because it gets checked against size of rank_names |
| 1381 |
|
| 1382 |
ASSERT_TRUE(active.primary_entity_rank() == stk::topology::INVALID_RANK); |
| 1383 |
|
| 1384 |
stk::io::fill_mesh("generated:1x1x4", bulkData); |
| 1385 |
|
| 1386 |
stk::unit_test_util::put_mesh_into_part(bulkData, active); |
| 1387 |
|
| 1388 |
ElemElemGraphTester graph(bulkData); |
| 1389 |
|
| 1390 |
size_t num_gold_edges = 6/bulkData.parallel_size(); |
| 1391 |
ASSERT_EQ(num_gold_edges, graph.num_edges()); |
| 1392 |
ASSERT_EQ(static_cast<unsigned>(nProc-1), graph.num_parallel_edges()); |
| 1393 |
|
| 1394 |
stk::mesh::EntityVector deactivated_elems; |
| 1395 |
|
| 1396 |
stk::mesh::Entity elem1 = bulkData.get_entity(stk::topology::ELEM_RANK, 1); |
| 1397 |
if (bulkData.is_valid(elem1) && bulkData.bucket(elem1).owned() ) |
| 1398 |
{ |
| 1399 |
deactivated_elems.push_back(elem1); |
| 1400 |
} |
| 1401 |
stk::mesh::Entity elem3 = bulkData.get_entity(stk::topology::ELEM_RANK, 3); |
| 1402 |
if (bulkData.is_valid(elem3) && bulkData.bucket(elem3).owned()) |
| 1403 |
{ |
| 1404 |
deactivated_elems.push_back(elem3); |
| 1405 |
} |
| 1406 |
|
| 1407 |
ElemGraphTestUtils::deactivate_elements(deactivated_elems, bulkData, active); |
| 1408 |
bulkData.modification_begin(); |
| 1409 |
bulkData.my_de_induce_unranked_part_from_nodes(deactivated_elems, active); |
| 1410 |
|
| 1411 |
for(size_t i=0; i<deactivated_elems.size(); ++i) |
| 1412 |
{ |
| 1413 |
EXPECT_FALSE(bulkData.bucket(deactivated_elems[i]).member(active)); |
| 1414 |
} |
| 1415 |
|
| 1416 |
const stk::mesh::BucketVector& all_node_buckets = bulkData.buckets(stk::topology::NODE_RANK); |
| 1417 |
for(size_t i=0; i<all_node_buckets.size(); ++i) |
| 1418 |
{ |
| 1419 |
const stk::mesh::Bucket& bucket = *all_node_buckets[i]; |
| 1420 |
for(size_t node_index=0; node_index<bucket.size(); ++node_index) |
| 1421 |
{ |
| 1422 |
stk::mesh::EntityId id = bulkData.identifier(bucket[node_index]); |
| 1423 |
if (id >=1 && id <= 4) |
| 1424 |
{ |
| 1425 |
EXPECT_FALSE(bucket.member(active)); |
| 1426 |
} |
| 1427 |
else |
| 1428 |
{ |
| 1429 |
EXPECT_TRUE(bucket.member(active)) << "for node id " << id << std::endl; |
| 1430 |
} |
| 1431 |
} |
| 1432 |
} |
| 1433 |
|
| 1434 |
bulkData.modification_end(); |
| 1435 |
ASSERT_EQ(static_cast<unsigned>(nProc-1), graph.num_parallel_edges()); |
| 1436 |
} |
| 1437 |
|
| 1438 |
TEST(ElementGraph, test_element_death) |
| 1439 |
{ |
| 1440 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 1441 |
|
| 1442 |
if(stk::parallel_machine_size(comm) <= 2) |
| 1443 |
{ |
| 1444 |
//IO error when this is <4. Shared face being attached to the wrong element |
| 1445 |
int xdim = stk::unit_test_util::get_command_line_option("--zdim", 4); |
| 1446 |
int ydim = xdim; |
| 1447 |
int zdim = xdim; // * stk::parallel_machine_size(comm); |
| 1448 |
|
| 1449 |
std::string filename = stk::unit_test_util::get_name_of_generated_mesh(xdim, ydim, zdim, "|nodeset:zZ"); |
| 1450 |
|
| 1451 |
{ |
| 1452 |
unsigned spatialDim = 3; |
| 1453 |
stk::mesh::MetaData meta(spatialDim); |
| 1454 |
stk::mesh::Part& faces_part = meta.declare_part_with_topology("surface_5", stk::topology::QUAD_4); |
| 1455 |
stk::mesh::PartVector boundary_mesh_parts { &faces_part }; |
| 1456 |
stk::io::put_io_part_attribute(faces_part); |
| 1457 |
BulkDataElementGraphTester bulkData(meta, comm); |
| 1458 |
|
| 1459 |
stk::mesh::Part& active = meta.declare_part("active", stk::topology::ELEMENT_RANK); |
| 1460 |
stk::io::fill_mesh(filename, bulkData); |
| 1461 |
|
| 1462 |
double start_graph = stk::wall_time(); |
| 1463 |
|
| 1464 |
ASSERT_TRUE(meta.get_part("block_1") != NULL); |
| 1465 |
|
| 1466 |
stk::mesh::Part& block_1 = *meta.get_part("block_1"); |
| 1467 |
|
| 1468 |
stk::unit_test_util::put_mesh_into_part(bulkData, active); |
| 1469 |
|
| 1470 |
std::ostringstream os; |
| 1471 |
os << "Proc id: " << bulkData.parallel_rank() << std::endl; |
| 1472 |
|
| 1473 |
stk::mesh::ElemElemGraph &elementGraph = bulkData.get_face_adjacent_element_graph(); |
| 1474 |
|
| 1475 |
double elapsed_graph_time = stk::wall_time() - start_graph; |
| 1476 |
os << "Time to create graph: " << elapsed_graph_time << std::endl; |
| 1477 |
|
| 1478 |
stk::mesh::EntityRank side_rank = meta.side_rank(); |
| 1479 |
|
| 1480 |
int num_time_steps = xdim * ydim * zdim; |
| 1481 |
double elapsed_death_time = 0; |
| 1482 |
|
| 1483 |
boundary_mesh_parts.push_back(&active); |
| 1484 |
|
| 1485 |
for(int i = 0; i < num_time_steps; ++i) |
| 1486 |
{ |
| 1487 |
stk::mesh::EntityVector killedElements = get_killed_elements(bulkData, i, active); |
| 1488 |
stk::unit_test_util::move_killed_elements_out_of_parts(bulkData, killedElements, {&block_1, &active}); |
| 1489 |
|
| 1490 |
stk::mesh::impl::ParallelSelectedInfo remoteActiveSelector; |
| 1491 |
stk::mesh::impl::populate_selected_value_for_remote_elements(bulkData, elementGraph, active, remoteActiveSelector); |
| 1492 |
|
| 1493 |
double start_time = stk::wall_time(); |
| 1494 |
process_killed_elements(bulkData, killedElements, active, remoteActiveSelector, boundary_mesh_parts, &boundary_mesh_parts); |
| 1495 |
elapsed_death_time += (stk::wall_time() - start_time); |
| 1496 |
} |
| 1497 |
|
| 1498 |
stk::mesh::Selector sel = block_1; |
| 1499 |
std::vector<size_t> counts1; |
| 1500 |
stk::mesh::comm_mesh_counts(bulkData, counts1, &sel); |
| 1501 |
|
| 1502 |
size_t num_active = counts1[stk::topology::ELEM_RANK]; |
| 1503 |
|
| 1504 |
stk::mesh::Selector sel2 = faces_part; |
| 1505 |
stk::mesh::comm_mesh_counts(bulkData, counts1, &sel2); |
| 1506 |
|
| 1507 |
size_t num_faces = counts1[side_rank]; |
| 1508 |
|
| 1509 |
EXPECT_EQ(2u, num_active); |
| 1510 |
EXPECT_EQ(5u, num_faces); |
| 1511 |
|
| 1512 |
if(stk::parallel_machine_rank(comm) == 0) |
| 1513 |
{ |
| 1514 |
os << "Total time: " << elapsed_death_time << std::endl; |
| 1515 |
os << "Total # of alive elements: " << num_active << std::endl; |
| 1516 |
os << "Total # of faces: " << num_faces << std::endl; |
| 1517 |
} |
| 1518 |
|
| 1519 |
std::cerr << os.str(); |
| 1520 |
} |
| 1521 |
} |
| 1522 |
} |
| 1523 |
|
| 1524 |
|
| 1525 |
class ElementDeathRestartTest |
| 1526 |
{ |
| 1527 |
public: |
| 1528 |
typedef stk::mesh::Field<double> ActiveFieldType; |
| 1529 |
|
| 1530 |
ElementDeathRestartTest() { |
| 1531 |
} |
| 1532 |
|
| 1533 |
virtual ~ElementDeathRestartTest() { |
| 1534 |
} |
| 1535 |
|
| 1536 |
void load_without_restart() |
| 1537 |
{ |
| 1538 |
initializeObjects(); |
| 1539 |
std::string filename = stk::unit_test_util::get_name_of_generated_mesh(1, 1, 2, "|sideset:zZ"); |
| 1540 |
stk::io::fill_mesh(filename, *bulkData); |
| 1541 |
stk::unit_test_util::put_mesh_into_part(*bulkData, *activePart); |
| 1542 |
} |
| 1543 |
|
| 1544 |
void read_restart_file(const std::string& filename) |
| 1545 |
{ |
| 1546 |
stk::io::StkMeshIoBroker stkIo(bulkData->parallel()); |
| 1547 |
stkIo.set_bulk_data(*bulkData); |
| 1548 |
stkIo.add_mesh_database(filename, stk::io::READ_RESTART); |
| 1549 |
stkIo.create_input_mesh(); |
| 1550 |
stkIo.populate_bulk_data(); |
| 1551 |
stk::io::MeshField ioActiveField(*deathStatusField); |
| 1552 |
stkIo.add_input_field(ioActiveField); |
| 1553 |
stkIo.read_defined_input_fields(restartTime); |
| 1554 |
} |
| 1555 |
|
| 1556 |
void load_with_restart(const std::string& filename) |
| 1557 |
{ |
| 1558 |
initializeObjects(); |
| 1559 |
read_restart_file(filename); |
| 1560 |
|
| 1561 |
stk::mesh::EntityVector deactivatedElements = set_active_part_from_field(); |
| 1562 |
|
| 1563 |
stk::mesh::impl::ParallelSelectedInfo remoteActiveSelector; |
| 1564 |
stk::mesh::impl::populate_selected_value_for_remote_elements(*bulkData, bulkData->get_face_adjacent_element_graph(), *activePart, remoteActiveSelector); |
| 1565 |
|
| 1566 |
stk::mesh::process_killed_elements(*bulkData, deactivatedElements, *activePart, remoteActiveSelector, partsForCreatingSides, NULL); |
| 1567 |
} |
| 1568 |
|
| 1569 |
void initializeObjects() |
| 1570 |
{ |
| 1571 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 1572 |
stk::mesh::MeshBuilder builder(comm); |
| 1573 |
builder.set_spatial_dimension(3); |
| 1574 |
builder.set_aura_option(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1575 |
bulkData = builder.create(); |
| 1576 |
metaData = &(bulkData->mesh_meta_data()); |
| 1577 |
stk::io::put_io_part_attribute(metaData->universal_part()); |
| 1578 |
deathStatusField = &metaData->declare_field<double>(stk::topology::ELEM_RANK,deathStatusFieldName); |
| 1579 |
stk::mesh::put_field_on_mesh(*deathStatusField,metaData->universal_part(), nullptr); |
| 1580 |
|
| 1581 |
activePart = &metaData->declare_part("active"); |
| 1582 |
deathPart = &metaData->declare_part("death_1", metaData->side_rank()); |
| 1583 |
const bool forceNoInduce = true; |
| 1584 |
sidesCreatedDuringDeath = &metaData->declare_part("sides_created_during_death", metaData->side_rank(),forceNoInduce); |
| 1585 |
|
| 1586 |
partsForCreatingSides.push_back(activePart); |
| 1587 |
partsForCreatingSides.push_back(sidesCreatedDuringDeath); |
| 1588 |
partsForCreatingSides.push_back(deathPart); |
| 1589 |
boundaryMeshParts.push_back(deathPart); |
| 1590 |
activePartVector.push_back(activePart); |
| 1591 |
|
| 1592 |
} |
| 1593 |
|
| 1594 |
void kill_element(int globalId) |
| 1595 |
{ |
| 1596 |
stk::mesh::Entity element = bulkData->get_entity(stk::topology::ELEM_RANK,globalId); |
| 1597 |
stk::mesh::EntityVector elementsToKill; |
| 1598 |
if (bulkData->is_valid(element)) |
| 1599 |
{ |
| 1600 |
elementsToKill.push_back(element); |
| 1601 |
} |
| 1602 |
stk::unit_test_util::move_killed_elements_out_of_parts(*bulkData, elementsToKill, activePartVector); |
| 1603 |
|
| 1604 |
stk::mesh::impl::ParallelSelectedInfo remoteActiveSelector; |
| 1605 |
stk::mesh::impl::populate_selected_value_for_remote_elements(*bulkData, bulkData->get_face_adjacent_element_graph(), *activePart, remoteActiveSelector); |
| 1606 |
|
| 1607 |
process_killed_elements(*bulkData, elementsToKill, *activePart, remoteActiveSelector, partsForCreatingSides, &boundaryMeshParts); |
| 1608 |
} |
| 1609 |
|
| 1610 |
void verify_mesh_before_death() const |
| 1611 |
{ |
| 1612 |
stk::mesh::Entity element1 = bulkData->get_entity(stk::topology::ELEM_RANK,1); |
| 1613 |
if (bulkData->is_valid(element1)) { |
| 1614 |
EXPECT_EQ(bulkData->num_faces(element1), 1u); |
| 1615 |
stk::mesh::Entity side4OfElement1 = bulkData->begin_faces(element1)[0]; |
| 1616 |
EXPECT_TRUE(bulkData->is_valid(side4OfElement1)); |
| 1617 |
EXPECT_EQ(bulkData->begin_face_ordinals(element1)[0], 4u); |
| 1618 |
EXPECT_FALSE(bulkData->bucket(side4OfElement1).member(*sidesCreatedDuringDeath)); |
| 1619 |
EXPECT_TRUE(bulkData->bucket(side4OfElement1).member(*activePart)); |
| 1620 |
} |
| 1621 |
} |
| 1622 |
|
| 1623 |
void verify_mesh_after_killing_element_1() const |
| 1624 |
{ |
| 1625 |
stk::mesh::Entity element1 = bulkData->get_entity(stk::topology::ELEM_RANK,1); |
| 1626 |
if (bulkData->is_valid(element1)) { |
| 1627 |
EXPECT_FALSE( bulkData->bucket(element1).member(*activePart) ); |
| 1628 |
EXPECT_EQ(bulkData->num_faces(element1), 2u); |
| 1629 |
const stk::mesh::Entity* sides = bulkData->begin_faces(element1); |
| 1630 |
const stk::mesh::ConnectivityOrdinal* sideOrdinals = bulkData->begin_face_ordinals(element1); |
| 1631 |
for (size_t sideI=0 ; sideI<2u ; ++sideI) { |
| 1632 |
stk::mesh::Entity side = sides[sideI]; |
| 1633 |
int sideOrdinal = sideOrdinals[sideI]; |
| 1634 |
if (sideOrdinal == 5) { |
| 1635 |
// Face between element1 and element2 |
| 1636 |
EXPECT_TRUE(bulkData->bucket(side).member(*activePart)); |
| 1637 |
EXPECT_TRUE(bulkData->bucket(side).member(*sidesCreatedDuringDeath)); |
| 1638 |
} |
| 1639 |
else { |
| 1640 |
// Side from generated mesh |
| 1641 |
EXPECT_FALSE(bulkData->bucket(side).member(*activePart)); |
| 1642 |
EXPECT_FALSE(bulkData->bucket(side).member(*sidesCreatedDuringDeath)); |
| 1643 |
} |
| 1644 |
} |
| 1645 |
} |
| 1646 |
} |
| 1647 |
|
| 1648 |
void verify_mesh_after_killing_element_2() const |
| 1649 |
{ |
| 1650 |
stk::mesh::Entity element1 = bulkData->get_entity(stk::topology::ELEM_RANK,1); |
| 1651 |
if (bulkData->is_valid(element1)) { |
| 1652 |
EXPECT_EQ(bulkData->num_faces(element1), 1u); |
| 1653 |
stk::mesh::Entity side = bulkData->begin_faces(element1)[0]; |
| 1654 |
stk::mesh::ConnectivityOrdinal sideOrdinalForSideFromGeneratedMesh = bulkData->begin_face_ordinals(element1)[0]; |
| 1655 |
EXPECT_EQ(sideOrdinalForSideFromGeneratedMesh, 4u); |
| 1656 |
EXPECT_FALSE(bulkData->bucket(side).member(*activePart)); |
| 1657 |
EXPECT_FALSE(bulkData->bucket(side).member(*sidesCreatedDuringDeath)); |
| 1658 |
} |
| 1659 |
|
| 1660 |
stk::mesh::Entity element2 = bulkData->get_entity(stk::topology::ELEM_RANK,2); |
| 1661 |
if (bulkData->is_valid(element2)) { |
| 1662 |
EXPECT_FALSE( bulkData->bucket(element2).member(*activePart) ); |
| 1663 |
EXPECT_EQ(bulkData->num_faces(element2), 1u); |
| 1664 |
stk::mesh::Entity side = bulkData->begin_faces(element2)[0]; |
| 1665 |
stk::mesh::ConnectivityOrdinal sideOrdinalForSideFromGeneratedMesh = bulkData->begin_face_ordinals(element2)[0]; |
| 1666 |
EXPECT_EQ(sideOrdinalForSideFromGeneratedMesh, 5u); |
| 1667 |
EXPECT_FALSE(bulkData->bucket(side).member(*activePart)); |
| 1668 |
EXPECT_FALSE(bulkData->bucket(side).member(*sidesCreatedDuringDeath)); |
| 1669 |
} |
| 1670 |
} |
| 1671 |
|
| 1672 |
stk::mesh::EntityVector set_active_part_from_field() |
| 1673 |
{ |
| 1674 |
stk::mesh::EntityVector deactivatedElements; |
| 1675 |
stk::mesh::EntityVector entities; |
| 1676 |
std::vector<stk::mesh::PartVector> addParts; |
| 1677 |
std::vector<stk::mesh::PartVector> removeParts; |
| 1678 |
const stk::mesh::BucketVector& elements = bulkData->buckets(stk::topology::ELEM_RANK); |
| 1679 |
const int deadElementStatus = 1; |
| 1680 |
for (size_t bucketI=0 ; bucketI<elements.size() ; ++bucketI) { |
| 1681 |
stk::mesh::Bucket& bucket = *(elements[bucketI]); |
| 1682 |
for (size_t elementI=0 ; elementI<bucket.size() ; ++elementI) { |
| 1683 |
stk::mesh::Entity element = bucket[elementI]; |
| 1684 |
double* deathStatus = stk::mesh::field_data(*deathStatusField,element); |
| 1685 |
if (static_cast<int>(deathStatus[0]) == deadElementStatus) { |
| 1686 |
entities.push_back(element); |
| 1687 |
addParts.push_back({}); |
| 1688 |
removeParts.push_back({activePart}); |
| 1689 |
deactivatedElements.push_back(element); |
| 1690 |
} else { |
| 1691 |
entities.push_back(element); |
| 1692 |
addParts.push_back({activePart}); |
| 1693 |
removeParts.push_back({}); |
| 1694 |
} |
| 1695 |
} |
| 1696 |
} |
| 1697 |
bulkData->batch_change_entity_parts( entities, addParts, removeParts); |
| 1698 |
return deactivatedElements; |
| 1699 |
} |
| 1700 |
|
| 1701 |
void set_active_field_from_part() |
| 1702 |
{ |
| 1703 |
const stk::mesh::BucketVector& elements = bulkData->buckets(stk::topology::ELEM_RANK); |
| 1704 |
for (size_t bucketI=0 ; bucketI<elements.size() ; ++bucketI) { |
| 1705 |
stk::mesh::Bucket& bucket = *(elements[bucketI]); |
| 1706 |
for (size_t elementI=0 ; elementI<bucket.size() ; ++elementI) { |
| 1707 |
stk::mesh::Entity element = bucket[elementI]; |
| 1708 |
double* deathStatus = stk::mesh::field_data(*deathStatusField,element); |
| 1709 |
deathStatus[0] = !bulkData->bucket(element).member(*activePart); |
| 1710 |
} |
| 1711 |
} |
| 1712 |
} |
| 1713 |
|
| 1714 |
void write_restart_file(std::string restartFileName) |
| 1715 |
{ |
| 1716 |
stk::mesh::FieldBase* deathStatusFieldBase = deathStatusField; |
| 1717 |
set_active_field_from_part(); |
| 1718 |
|
| 1719 |
stk::io::StkMeshIoBroker stkIo(bulkData->parallel()); |
| 1720 |
stkIo.set_bulk_data(*bulkData); |
| 1721 |
size_t fileHandle = stkIo.create_output_mesh(restartFileName, stk::io::WRITE_RESTART); |
| 1722 |
stkIo.write_output_mesh(fileHandle); |
| 1723 |
stkIo.add_field(fileHandle, *deathStatusFieldBase); |
| 1724 |
stkIo.begin_output_step(fileHandle, restartTime); |
| 1725 |
stkIo.write_defined_output_fields(fileHandle); |
| 1726 |
stkIo.end_output_step(fileHandle); |
| 1727 |
} |
| 1728 |
public: |
| 1729 |
stk::mesh::MetaData* metaData = nullptr; |
| 1730 |
std::shared_ptr<stk::mesh::BulkData> bulkData; |
| 1731 |
stk::mesh::Part* activePart; |
| 1732 |
stk::mesh::PartVector activePartVector; |
| 1733 |
stk::mesh::PartVector partsForCreatingSides; |
| 1734 |
stk::mesh::PartVector boundaryMeshParts; |
| 1735 |
stk::mesh::Part* deathPart; |
| 1736 |
stk::mesh::Part* sidesCreatedDuringDeath; |
| 1737 |
ActiveFieldType* deathStatusField; |
| 1738 |
std::string deathStatusFieldName = "death_status"; |
| 1739 |
double restartTime = 1.0; |
| 1740 |
|
| 1741 |
}; |
| 1742 |
|
| 1743 |
|
| 1744 |
TEST(ElementDeath, test_element_death_without_restart) |
| 1745 |
{ |
| 1746 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 1747 |
if(stk::parallel_machine_size(comm) <= 2) |
| 1748 |
{ |
| 1749 |
ElementDeathRestartTest elementDeathTest; |
| 1750 |
elementDeathTest.load_without_restart(); |
| 1751 |
elementDeathTest.verify_mesh_before_death(); |
| 1752 |
elementDeathTest.kill_element(1); |
| 1753 |
elementDeathTest.verify_mesh_after_killing_element_1(); |
| 1754 |
elementDeathTest.kill_element(2); |
| 1755 |
elementDeathTest.verify_mesh_after_killing_element_2(); |
| 1756 |
} |
| 1757 |
} |
| 1758 |
|
| 1759 |
TEST(ElementDeath, test_element_death_with_restart) |
| 1760 |
{ |
| 1761 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 1762 |
if(stk::parallel_machine_size(comm) <= 2) |
| 1763 |
{ |
| 1764 |
{ |
| 1765 |
ElementDeathRestartTest elementDeathTest; |
| 1766 |
elementDeathTest.load_without_restart(); |
| 1767 |
elementDeathTest.verify_mesh_before_death(); |
| 1768 |
elementDeathTest.kill_element(1); |
| 1769 |
elementDeathTest.verify_mesh_after_killing_element_1(); |
| 1770 |
elementDeathTest.write_restart_file("elemDeathRestartFile.exo"); |
| 1771 |
} |
| 1772 |
{ |
| 1773 |
ElementDeathRestartTest elementDeathTest; |
| 1774 |
elementDeathTest.load_with_restart("elemDeathRestartFile.exo"); |
| 1775 |
elementDeathTest.verify_mesh_after_killing_element_1(); |
| 1776 |
elementDeathTest.kill_element(2); |
| 1777 |
elementDeathTest.verify_mesh_after_killing_element_2(); |
| 1778 |
} |
| 1779 |
stk::unit_test_util::delete_mesh("elemDeathRestartFile.exo"); |
| 1780 |
} |
| 1781 |
} |
| 1782 |
|
| 1783 |
//EndDocExample1 |
| 1784 |
|
| 1785 |
TEST( ElementGraph, HexHexHexSerial ) |
| 1786 |
{ |
| 1787 |
// ID.proc |
| 1788 |
// |
| 1789 |
// 3.0------------7.0-----------11.0-----------15.0 |
| 1790 |
// /| /| /| /| |
| 1791 |
// / | / | / | / | |
| 1792 |
// / | / | / | / | |
| 1793 |
// 4.0------------8.0-----------12.0-----------16.0 | |
| 1794 |
// | | | | | | | | |
| 1795 |
// | | 1.0 | | 2.0 | | 3.0 | | |
| 1796 |
// | | | | | | | | |
| 1797 |
// | 2.0---------|--6.0---------|-10.0---------|-14.0 |
| 1798 |
// | / | / | / | / |
| 1799 |
// | / | / | / | / |
| 1800 |
// |/ |/ |/ |/ |
| 1801 |
// 1.0------------5.0------------9.0-----------13.0 |
| 1802 |
// |
| 1803 |
|
| 1804 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 1805 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 1806 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 1807 |
|
| 1808 |
if(p_size != 1u) |
| 1809 |
{ |
| 1810 |
return; |
| 1811 |
} |
| 1812 |
|
| 1813 |
const unsigned spatialDim = 3; |
| 1814 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 1815 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 1816 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 1817 |
|
| 1818 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 1819 |
meta.commit(); |
| 1820 |
|
| 1821 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 1822 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 1823 |
{ 5, 6, 7, 8, 9, 10, 11, 12 }, |
| 1824 |
{ 9, 10, 11, 12, 13, 14, 15, 16 } |
| 1825 |
}; |
| 1826 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2, 3 }; |
| 1827 |
stk::mesh::EntityId hexElemOwningProc[] = { 0, 0, 0 }; |
| 1828 |
|
| 1829 |
mesh.modification_begin(); |
| 1830 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 1831 |
if (hexElemOwningProc[i] == p_rank) { |
| 1832 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 1833 |
} |
| 1834 |
} |
| 1835 |
mesh.modification_end(); |
| 1836 |
|
| 1837 |
ElemElemGraphTester elemElemGraph(mesh); |
| 1838 |
|
| 1839 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 1840 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 1841 |
const Entity hex3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 1842 |
|
| 1843 |
{ |
| 1844 |
// Connectivity for Hex Element 1 |
| 1845 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 1846 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex1, 0); |
| 1847 |
EXPECT_EQ(5, elem_via_side.side); |
| 1848 |
EXPECT_EQ(hex2, elem_via_side.element); |
| 1849 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 1850 |
} |
| 1851 |
|
| 1852 |
// Connectivity for Hex Element 2 |
| 1853 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(hex2)); |
| 1854 |
impl::ElementViaSidePair elem0_via_side = elemElemGraph.get_connected_element_and_via_side(hex2, 0); |
| 1855 |
impl::ElementViaSidePair elem1_via_side = elemElemGraph.get_connected_element_and_via_side(hex2, 1); |
| 1856 |
EXPECT_EQ(4, elem0_via_side.side); |
| 1857 |
EXPECT_EQ(5, elem1_via_side.side); |
| 1858 |
EXPECT_EQ(hex1, elem0_via_side.element); |
| 1859 |
EXPECT_EQ(hex3, elem1_via_side.element); |
| 1860 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 1861 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex2, 1)); |
| 1862 |
|
| 1863 |
{ |
| 1864 |
// Connectivity for Hex Element 3 |
| 1865 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex3)); |
| 1866 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex3, 0); |
| 1867 |
EXPECT_EQ(4, elem_via_side.side); |
| 1868 |
EXPECT_EQ(hex2, elem_via_side.element); |
| 1869 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex3, 0)); |
| 1870 |
} |
| 1871 |
EXPECT_EQ(4u, elemElemGraph.num_edges()); |
| 1872 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 1873 |
} |
| 1874 |
|
| 1875 |
TEST( ElementGraph, HexShellSerial ) |
| 1876 |
{ |
| 1877 |
// ID.proc |
| 1878 |
// |
| 1879 |
// 3.0------------7.0 |
| 1880 |
// /| /| |
| 1881 |
// / | / | |
| 1882 |
// / | / | |
| 1883 |
// 4.0------------8.0 | |
| 1884 |
// | | | | |
| 1885 |
// | | 1.0 |2.0| |
| 1886 |
// | | | | |
| 1887 |
// | 2.0---------|--6.0 |
| 1888 |
// | / | / |
| 1889 |
// | / | / |
| 1890 |
// |/ |/ |
| 1891 |
// 1.0------------5.0 |
| 1892 |
// ^ |
| 1893 |
// | |
| 1894 |
// ---- Single shell element |
| 1895 |
|
| 1896 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 1897 |
int p_size = stk::parallel_machine_size(pm); |
| 1898 |
|
| 1899 |
if(p_size > 1) |
| 1900 |
{ |
| 1901 |
return; |
| 1902 |
} |
| 1903 |
|
| 1904 |
const unsigned spatialDim = 3; |
| 1905 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 1906 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 1907 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 1908 |
|
| 1909 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 1910 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 1911 |
meta.commit(); |
| 1912 |
|
| 1913 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 1914 |
{ 1, 2, 3, 4, 5, 6, 7, 8 } |
| 1915 |
}; |
| 1916 |
stk::mesh::EntityId hexElemIDs[] = { 1 }; |
| 1917 |
|
| 1918 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 1919 |
{ 5, 6, 7, 8 } |
| 1920 |
}; |
| 1921 |
stk::mesh::EntityId shellElemIDs[] = { 2 }; |
| 1922 |
|
| 1923 |
mesh.modification_begin(); |
| 1924 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 1925 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 1926 |
} |
| 1927 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 1928 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 1929 |
} |
| 1930 |
mesh.modification_end(); |
| 1931 |
|
| 1932 |
ElemElemGraphTester elemElemGraph(mesh); |
| 1933 |
|
| 1934 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 1935 |
const Entity shell2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 1936 |
|
| 1937 |
{ |
| 1938 |
// Connectivity for Hex Element 1 |
| 1939 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 1940 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex1, 0); |
| 1941 |
EXPECT_EQ(5, elem_via_side.side); |
| 1942 |
EXPECT_EQ(shell2, elem_via_side.element); |
| 1943 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 1944 |
} |
| 1945 |
{ |
| 1946 |
// Connectivity for Shell Element 2 |
| 1947 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(shell2)); |
| 1948 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(shell2, 0); |
| 1949 |
EXPECT_EQ(1, elem_via_side.side); |
| 1950 |
EXPECT_EQ(hex1, elem_via_side.element); |
| 1951 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(shell2, 0)); |
| 1952 |
} |
| 1953 |
EXPECT_EQ(2u, elemElemGraph.num_edges()); |
| 1954 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 1955 |
} |
| 1956 |
|
| 1957 |
TEST( ElementGraph, AdjacentHexShellSerial ) |
| 1958 |
{ |
| 1959 |
// ID.proc |
| 1960 |
// |
| 1961 |
// 12.0-----------11.0 |
| 1962 |
// /| /| |
| 1963 |
// / | / | |
| 1964 |
// / | / | |
| 1965 |
// 9.0-----------10.0 | |
| 1966 |
// | | | | |
| 1967 |
// | | 2.0 |4.0| |
| 1968 |
// | | | | |
| 1969 |
// | 8.0---------|--7.0 |
| 1970 |
// | /| | /| |
| 1971 |
// | / | | / | |
| 1972 |
// |/ | |/ | |
| 1973 |
// 5.0------------6.0 | |
| 1974 |
// | | | | |
| 1975 |
// | | 1.0 |3.0| |
| 1976 |
// | | | | |
| 1977 |
// | 4.0---------|--3.0 |
| 1978 |
// | / | / |
| 1979 |
// | / | / |
| 1980 |
// |/ |/ |
| 1981 |
// 1.0------------2.0 |
| 1982 |
// ^ |
| 1983 |
// | |
| 1984 |
// ---- Single shell element |
| 1985 |
|
| 1986 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 1987 |
int p_size = stk::parallel_machine_size(pm); |
| 1988 |
|
| 1989 |
if(p_size > 1) |
| 1990 |
{ |
| 1991 |
GTEST_SKIP(); |
| 1992 |
} |
| 1993 |
|
| 1994 |
const unsigned spatialDim = 3; |
| 1995 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 1996 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 1997 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 1998 |
|
| 1999 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 2000 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 2001 |
meta.commit(); |
| 2002 |
|
| 2003 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 2004 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 2005 |
{ 5, 6, 7, 8, 9, 10, 11, 12 } |
| 2006 |
}; |
| 2007 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2 }; |
| 2008 |
|
| 2009 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 2010 |
{ 2, 3, 7, 6 }, |
| 2011 |
{ 6, 7, 11, 10 }, |
| 2012 |
}; |
| 2013 |
stk::mesh::EntityId shellElemIDs[] = { 3, 4 }; |
| 2014 |
|
| 2015 |
mesh.modification_begin(); |
| 2016 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 2017 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 2018 |
} |
| 2019 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 2020 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 2021 |
} |
| 2022 |
mesh.modification_end(); |
| 2023 |
|
| 2024 |
ElemElemGraphTester elemElemGraph(mesh); |
| 2025 |
|
| 2026 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 2027 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 2028 |
const Entity shell3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 2029 |
const Entity shell4 = mesh.get_entity(stk::topology::ELEM_RANK, 4); |
| 2030 |
|
| 2031 |
// Connectivity for Hex Element 1 |
| 2032 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(hex1)); |
| 2033 |
expect_correct_connected_element_via_side(elemElemGraph, hex1, 0, hex2, 5); |
| 2034 |
expect_correct_connected_element_via_side(elemElemGraph, hex1, 1, shell3, 1); |
| 2035 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 2036 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex1, 1)); |
| 2037 |
|
| 2038 |
// Connectivity for Hex Element 2 |
| 2039 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(hex2)); |
| 2040 |
expect_correct_connected_element_via_side(elemElemGraph, hex2, 0, hex1, 4); |
| 2041 |
expect_correct_connected_element_via_side(elemElemGraph, hex2, 1, shell4, 1); |
| 2042 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 2043 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex2, 1)); |
| 2044 |
|
| 2045 |
// Connectivity for Shell Element 3 |
| 2046 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell3)); |
| 2047 |
expect_correct_connected_element_via_side(elemElemGraph, shell3, 0, hex1, 1); |
| 2048 |
expect_correct_connected_element_via_side(elemElemGraph, shell3, 1, shell4, 4); // edge |
| 2049 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(shell3, 0)); |
| 2050 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(shell3, 1)); // connected to shell4 through edge |
| 2051 |
|
| 2052 |
// Connectivity for Shell Element 4 |
| 2053 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell4)); |
| 2054 |
expect_correct_connected_element_via_side(elemElemGraph, shell4, 0, hex2, 1); |
| 2055 |
expect_correct_connected_element_via_side(elemElemGraph, shell4, 1, shell3, 2); // edge |
| 2056 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(shell4, 0)); |
| 2057 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(shell4, 1)); // connected to shell3 through edge |
| 2058 |
|
| 2059 |
EXPECT_EQ(8u, elemElemGraph.num_edges()); |
| 2060 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 2061 |
EXPECT_EQ(0u, elemElemGraph.num_coincident_edges()); |
| 2062 |
} |
| 2063 |
|
| 2064 |
TEST( ElementGraph, HexShellHexSerial ) |
| 2065 |
{ |
| 2066 |
// ID.proc |
| 2067 |
// |
| 2068 |
// 3.0------------7.0-----------11.0 |
| 2069 |
// /| /| /| |
| 2070 |
// / | / | / | |
| 2071 |
// / | / | / | |
| 2072 |
// 4.0------------8.0-----------12.0 | |
| 2073 |
// | | | | | | |
| 2074 |
// | | 1.0 |3.0| 2.0 | | |
| 2075 |
// | | | | | | |
| 2076 |
// | 2.0---------|--6.0---------|-10.0 |
| 2077 |
// | / | / | / |
| 2078 |
// | / | / | / |
| 2079 |
// |/ |/ |/ |
| 2080 |
// 1.0------------5.0------------9.0 |
| 2081 |
// ^ |
| 2082 |
// | |
| 2083 |
// ---- Single shell element |
| 2084 |
|
| 2085 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 2086 |
int p_size = stk::parallel_machine_size(pm); |
| 2087 |
|
| 2088 |
if(p_size > 1) |
| 2089 |
{ |
| 2090 |
return; |
| 2091 |
} |
| 2092 |
|
| 2093 |
const unsigned spatialDim = 3; |
| 2094 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 2095 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 2096 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 2097 |
|
| 2098 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 2099 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 2100 |
meta.commit(); |
| 2101 |
|
| 2102 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 2103 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 2104 |
{ 5, 6, 7, 8, 9, 10, 11, 12 } |
| 2105 |
}; |
| 2106 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2 }; |
| 2107 |
|
| 2108 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 2109 |
{ 5, 6, 7, 8 } |
| 2110 |
}; |
| 2111 |
stk::mesh::EntityId shellElemIDs[] = { 3 }; |
| 2112 |
|
| 2113 |
mesh.modification_begin(); |
| 2114 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 2115 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 2116 |
} |
| 2117 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 2118 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 2119 |
} |
| 2120 |
mesh.modification_end(); |
| 2121 |
|
| 2122 |
ElemElemGraphTester elemElemGraph(mesh); |
| 2123 |
|
| 2124 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 2125 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 2126 |
const Entity shell3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 2127 |
|
| 2128 |
{ |
| 2129 |
// Connectivity for Hex Element 1 |
| 2130 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 2131 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex1, 0); |
| 2132 |
EXPECT_EQ(5, elem_via_side.side); |
| 2133 |
EXPECT_EQ(shell3, elem_via_side.element); |
| 2134 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 2135 |
} |
| 2136 |
{ |
| 2137 |
// Connectivity for Hex Element 2 |
| 2138 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex2)); |
| 2139 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex2, 0); |
| 2140 |
EXPECT_EQ(4, elem_via_side.side); |
| 2141 |
EXPECT_EQ(shell3, elem_via_side.element); |
| 2142 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 2143 |
} |
| 2144 |
// Connectivity for Shell Element 3 |
| 2145 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell3)); |
| 2146 |
impl::ElementViaSidePair elem0_via_side = elemElemGraph.get_connected_element_and_via_side(shell3, 0); |
| 2147 |
impl::ElementViaSidePair elem1_via_side = elemElemGraph.get_connected_element_and_via_side(shell3, 1); |
| 2148 |
EXPECT_EQ(1, elem0_via_side.side); |
| 2149 |
EXPECT_EQ(0, elem1_via_side.side); |
| 2150 |
EXPECT_EQ(hex1, elem0_via_side.element); |
| 2151 |
EXPECT_EQ(hex2, elem1_via_side.element); |
| 2152 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(shell3, 0)); |
| 2153 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(shell3, 1)); |
| 2154 |
|
| 2155 |
EXPECT_EQ(4u, elemElemGraph.num_edges()); |
| 2156 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 2157 |
} |
| 2158 |
|
| 2159 |
TEST( ElementGraph, Hex0Hex0Hex1Parallel ) |
| 2160 |
{ |
| 2161 |
// ID.proc |
| 2162 |
// |
| 2163 |
// 3.0------------7.0-----------11.0-----------15.1 |
| 2164 |
// /| /| /| /| |
| 2165 |
// / | / | / | / | |
| 2166 |
// / | / | / | / | |
| 2167 |
// 4.0------------8.0-----------12.0-----------16.1 | |
| 2168 |
// | | | | | | | | |
| 2169 |
// | | 1.0 | | 2.0 | | 3.1 | | |
| 2170 |
// | | | | | | | | |
| 2171 |
// | 2.0---------|--6.0---------|-10.0---------|-14.1 |
| 2172 |
// | / | / | / | / |
| 2173 |
// | / | / | / | / |
| 2174 |
// |/ |/ |/ |/ |
| 2175 |
// 1.0------------5.0------------9.0-----------13.1 |
| 2176 |
// |
| 2177 |
|
| 2178 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 2179 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 2180 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 2181 |
|
| 2182 |
if(p_size != 2u) |
| 2183 |
{ |
| 2184 |
return; |
| 2185 |
} |
| 2186 |
|
| 2187 |
const unsigned spatialDim = 3; |
| 2188 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 2189 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 2190 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 2191 |
|
| 2192 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 2193 |
meta.commit(); |
| 2194 |
|
| 2195 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 2196 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 2197 |
{ 5, 6, 7, 8, 9, 10, 11, 12 }, |
| 2198 |
{ 9, 10, 11, 12, 13, 14, 15, 16 } |
| 2199 |
}; |
| 2200 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2, 3 }; |
| 2201 |
stk::mesh::EntityId hexElemOwningProc[] = { 0, 0, 1 }; |
| 2202 |
|
| 2203 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 2204 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 2205 |
{ |
| 2206 |
{ 0, 9, 1 }, // proc 0 |
| 2207 |
{ 0, 10, 1 }, |
| 2208 |
{ 0, 11, 1 }, |
| 2209 |
{ 0, 12, 1 }, |
| 2210 |
{ 1, 9, 0 }, // proc 1 |
| 2211 |
{ 1, 10, 0 }, |
| 2212 |
{ 1, 11, 0 }, |
| 2213 |
{ 1, 12, 0 } |
| 2214 |
}; |
| 2215 |
|
| 2216 |
mesh.modification_begin(); |
| 2217 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 2218 |
if (hexElemOwningProc[i] == p_rank) { |
| 2219 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 2220 |
} |
| 2221 |
} |
| 2222 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs ); |
| 2223 |
mesh.modification_end(); |
| 2224 |
|
| 2225 |
ElemElemGraphTester elemElemGraph(mesh); |
| 2226 |
|
| 2227 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 2228 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 2229 |
const Entity hex3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 2230 |
|
| 2231 |
if (p_rank == 0) { |
| 2232 |
{ |
| 2233 |
// Connectivity for Hex Element 1 |
| 2234 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 2235 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex1, 0); |
| 2236 |
EXPECT_EQ(5, elem_via_side.side); |
| 2237 |
EXPECT_EQ(hex2, elem_via_side.element); |
| 2238 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 2239 |
} |
| 2240 |
{ |
| 2241 |
// Connectivity for Hex Element 2 |
| 2242 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(hex2)); |
| 2243 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex2, 0); |
| 2244 |
EXPECT_EQ(4, elem_via_side.side); |
| 2245 |
EXPECT_EQ(hex1, elem_via_side.element); |
| 2246 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 1).side); |
| 2247 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 1).id); |
| 2248 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 2249 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 1)); |
| 2250 |
} |
| 2251 |
EXPECT_EQ(3u, elemElemGraph.num_edges()); |
| 2252 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2253 |
} |
| 2254 |
else if (p_rank == 1) { |
| 2255 |
// Connectivity for Hex Element 3 |
| 2256 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex3)); |
| 2257 |
impl::IdViaSidePair remote_elem_id_via_side = elemElemGraph.get_connected_remote_id_and_via_side(hex3, 0); |
| 2258 |
EXPECT_EQ(2u, remote_elem_id_via_side.id); |
| 2259 |
EXPECT_EQ(4, remote_elem_id_via_side.side); |
| 2260 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex3, 0)); |
| 2261 |
|
| 2262 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 2263 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2264 |
} |
| 2265 |
} |
| 2266 |
|
| 2267 |
TEST( ElementGraph, OneHex ) |
| 2268 |
{ |
| 2269 |
if (1 == stk::parallel_machine_size(MPI_COMM_WORLD)) |
| 2270 |
{ |
| 2271 |
const unsigned spatialDim = 3; |
| 2272 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, MPI_COMM_WORLD, stk::mesh::BulkData::NO_AUTO_AURA); |
| 2273 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 2274 |
stk::io::fill_mesh("generated:1x1x1", bulk); |
| 2275 |
|
| 2276 |
bulk.get_face_adjacent_element_graph().write_graph(std::cerr, "Before"); |
| 2277 |
|
| 2278 |
bulk.modification_begin(); |
| 2279 |
stk::mesh::Entity elem1 = bulk.get_entity(stk::topology::ELEM_RANK,1); |
| 2280 |
bulk.destroy_entity(elem1); |
| 2281 |
bulk.modification_end(); |
| 2282 |
|
| 2283 |
bulk.get_face_adjacent_element_graph().write_graph(std::cerr, "After"); |
| 2284 |
EXPECT_EQ(0u, bulk.get_face_adjacent_element_graph().size()); |
| 2285 |
} |
| 2286 |
} |
| 2287 |
|
| 2288 |
TEST( ElementGraph, Hex0Hex1Hex0Parallel ) |
| 2289 |
{ |
| 2290 |
// ID.proc |
| 2291 |
// |
| 2292 |
// 3.0------------7.0-----------11.0-----------15.0 |
| 2293 |
// /| /| /| /| |
| 2294 |
// / | / | / | / | |
| 2295 |
// / | / | / | / | |
| 2296 |
// 4.0------------8.0-----------12.0-----------16.0 | |
| 2297 |
// | | | | | | | | |
| 2298 |
// | | 1.0 | | 2.1 | | 3.0 | | |
| 2299 |
// | | | | | | | | |
| 2300 |
// | 2.0---------|--6.0---------|-10.0---------|-14.0 |
| 2301 |
// | / | / | / | / |
| 2302 |
// | / | / | / | / |
| 2303 |
// |/ |/ |/ |/ |
| 2304 |
// 1.0------------5.0------------9.0-----------13.0 |
| 2305 |
// |
| 2306 |
|
| 2307 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 2308 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 2309 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 2310 |
|
| 2311 |
if(p_size != 2u) |
| 2312 |
{ |
| 2313 |
return; |
| 2314 |
} |
| 2315 |
|
| 2316 |
const unsigned spatialDim = 3; |
| 2317 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 2318 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 2319 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 2320 |
|
| 2321 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 2322 |
meta.commit(); |
| 2323 |
|
| 2324 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 2325 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 2326 |
{ 5, 6, 7, 8, 9, 10, 11, 12 }, |
| 2327 |
{ 9, 10, 11, 12, 13, 14, 15, 16 } |
| 2328 |
}; |
| 2329 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2, 3 }; |
| 2330 |
stk::mesh::EntityId hexElemOwningProc[] = { 0, 1, 0 }; |
| 2331 |
|
| 2332 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 2333 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 2334 |
{ |
| 2335 |
{ 0, 5, 1 }, // proc 0 |
| 2336 |
{ 0, 6, 1 }, |
| 2337 |
{ 0, 7, 1 }, |
| 2338 |
{ 0, 8, 1 }, |
| 2339 |
{ 0, 9, 1 }, |
| 2340 |
{ 0, 10, 1 }, |
| 2341 |
{ 0, 11, 1 }, |
| 2342 |
{ 0, 12, 1 }, |
| 2343 |
{ 1, 5, 0 }, // proc 1 |
| 2344 |
{ 1, 6, 0 }, |
| 2345 |
{ 1, 7, 0 }, |
| 2346 |
{ 1, 8, 0 }, |
| 2347 |
{ 1, 9, 0 }, |
| 2348 |
{ 1, 10, 0 }, |
| 2349 |
{ 1, 11, 0 }, |
| 2350 |
{ 1, 12, 0 } |
| 2351 |
}; |
| 2352 |
|
| 2353 |
mesh.modification_begin(); |
| 2354 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 2355 |
if (hexElemOwningProc[i] == p_rank) { |
| 2356 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 2357 |
} |
| 2358 |
} |
| 2359 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs ); |
| 2360 |
mesh.modification_end(); |
| 2361 |
|
| 2362 |
ElemElemGraphTester elemElemGraph(mesh); |
| 2363 |
|
| 2364 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 2365 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 2366 |
const Entity hex3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 2367 |
|
| 2368 |
if (p_rank == 0) { |
| 2369 |
// Connectivity for Hex Element 1 |
| 2370 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 2371 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).side); |
| 2372 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).id); |
| 2373 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 2374 |
|
| 2375 |
// Connectivity for Hex Element 3 |
| 2376 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex3)); |
| 2377 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex3, 0).side); |
| 2378 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(hex3, 0).id); |
| 2379 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex3, 0)); |
| 2380 |
} |
| 2381 |
else if (p_rank == 1) { |
| 2382 |
// Connectivity for Hex Element 2 |
| 2383 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(hex2)); |
| 2384 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).side); |
| 2385 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 1).side); |
| 2386 |
EXPECT_EQ(1u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).id); |
| 2387 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 1).id); |
| 2388 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 2389 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 1)); |
| 2390 |
} |
| 2391 |
|
| 2392 |
EXPECT_EQ(2u, elemElemGraph.num_edges()); |
| 2393 |
EXPECT_EQ(2u, elemElemGraph.num_parallel_edges()); |
| 2394 |
} |
| 2395 |
|
| 2396 |
TEST( ElementGraph, Hex0Hex1Hex2Parallel ) |
| 2397 |
{ |
| 2398 |
// ID.proc |
| 2399 |
// |
| 2400 |
// 3.0------------7.0-----------11.1-----------15.2 |
| 2401 |
// /| /| /| /| |
| 2402 |
// / | / | / | / | |
| 2403 |
// / | / | / | / | |
| 2404 |
// 4.0------------8.0-----------12.1-----------16.2 | |
| 2405 |
// | | | | | | | | |
| 2406 |
// | | 1.0 | | 2.1 | | 3.2 | | |
| 2407 |
// | | | | | | | | |
| 2408 |
// | 2.0---------|--6.0---------|-10.1---------|-14.2 |
| 2409 |
// | / | / | / | / |
| 2410 |
// | / | / | / | / |
| 2411 |
// |/ |/ |/ |/ |
| 2412 |
// 1.0------------5.0------------9.1-----------13.2 |
| 2413 |
// |
| 2414 |
|
| 2415 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 2416 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 2417 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 2418 |
|
| 2419 |
if(p_size != 3u) |
| 2420 |
{ |
| 2421 |
return; |
| 2422 |
} |
| 2423 |
|
| 2424 |
const unsigned spatialDim = 3; |
| 2425 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 2426 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 2427 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 2428 |
|
| 2429 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 2430 |
meta.commit(); |
| 2431 |
|
| 2432 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 2433 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 2434 |
{ 5, 6, 7, 8, 9, 10, 11, 12 }, |
| 2435 |
{ 9, 10, 11, 12, 13, 14, 15, 16 } |
| 2436 |
}; |
| 2437 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2, 3 }; |
| 2438 |
stk::mesh::EntityId hexElemOwningProc[] = { 0, 1, 2 }; |
| 2439 |
|
| 2440 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 2441 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 2442 |
{ |
| 2443 |
{ 0, 5, 1 }, // proc 0 |
| 2444 |
{ 0, 6, 1 }, |
| 2445 |
{ 0, 7, 1 }, |
| 2446 |
{ 0, 8, 1 }, |
| 2447 |
{ 1, 5, 0 }, // proc 1 |
| 2448 |
{ 1, 6, 0 }, |
| 2449 |
{ 1, 7, 0 }, |
| 2450 |
{ 1, 8, 0 }, |
| 2451 |
{ 1, 9, 2 }, |
| 2452 |
{ 1, 10, 2 }, |
| 2453 |
{ 1, 11, 2 }, |
| 2454 |
{ 1, 12, 2 }, |
| 2455 |
{ 2, 9, 1 }, // proc 2 |
| 2456 |
{ 2, 10, 1 }, |
| 2457 |
{ 2, 11, 1 }, |
| 2458 |
{ 2, 12, 1 } |
| 2459 |
}; |
| 2460 |
|
| 2461 |
mesh.modification_begin(); |
| 2462 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 2463 |
if (hexElemOwningProc[i] == p_rank) { |
| 2464 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 2465 |
} |
| 2466 |
} |
| 2467 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs ); |
| 2468 |
mesh.modification_end(); |
| 2469 |
|
| 2470 |
ElemElemGraphTester elemElemGraph(mesh); |
| 2471 |
|
| 2472 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 2473 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 2474 |
const Entity hex3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 2475 |
|
| 2476 |
if (p_rank == 0) { |
| 2477 |
// Connectivity for Hex Element 1 |
| 2478 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 2479 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).side); |
| 2480 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).id); |
| 2481 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 2482 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 2483 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2484 |
} |
| 2485 |
else if (p_rank == 1) { |
| 2486 |
// Connectivity for Hex Element 2 |
| 2487 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(hex2)); |
| 2488 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).side); |
| 2489 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 1).side); |
| 2490 |
EXPECT_EQ(1u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).id); |
| 2491 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 1).id); |
| 2492 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 2493 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 1)); |
| 2494 |
EXPECT_EQ(2u, elemElemGraph.num_edges()); |
| 2495 |
EXPECT_EQ(2u, elemElemGraph.num_parallel_edges()); |
| 2496 |
} |
| 2497 |
else if (p_rank == 2) { |
| 2498 |
// Connectivity for Hex Element 3 |
| 2499 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex3)); |
| 2500 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex3, 0).side); |
| 2501 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(hex3, 0).id); |
| 2502 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex3, 0)); |
| 2503 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 2504 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2505 |
} |
| 2506 |
} |
| 2507 |
|
| 2508 |
TEST( ElementGraph, Hex0Shell1Parallel ) |
| 2509 |
{ |
| 2510 |
// ID.proc |
| 2511 |
// |
| 2512 |
// 3.0------------7.0 |
| 2513 |
// /| /| |
| 2514 |
// / | / | |
| 2515 |
// / | / | |
| 2516 |
// 4.0------------8.0 | |
| 2517 |
// | | | | |
| 2518 |
// | | 1.0 |2.1| |
| 2519 |
// | | | | |
| 2520 |
// | 2.0---------|--6.0 |
| 2521 |
// | / | / |
| 2522 |
// | / | / |
| 2523 |
// |/ |/ |
| 2524 |
// 1.0------------5.0 |
| 2525 |
// ^ |
| 2526 |
// | |
| 2527 |
// ---- Single shell element |
| 2528 |
|
| 2529 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 2530 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 2531 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 2532 |
|
| 2533 |
if(p_size != 2u) |
| 2534 |
{ |
| 2535 |
return; |
| 2536 |
} |
| 2537 |
|
| 2538 |
const unsigned spatialDim = 3; |
| 2539 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 2540 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 2541 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 2542 |
|
| 2543 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 2544 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 2545 |
meta.commit(); |
| 2546 |
|
| 2547 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 2548 |
{ 1, 2, 3, 4, 5, 6, 7, 8 } |
| 2549 |
}; |
| 2550 |
stk::mesh::EntityId hexElemIDs[] = { 1 }; |
| 2551 |
stk::mesh::EntityId hexElemOwningProc[] = { 0 }; |
| 2552 |
|
| 2553 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 2554 |
{ 5, 6, 7, 8 } |
| 2555 |
}; |
| 2556 |
stk::mesh::EntityId shellElemIDs[] = { 2 }; |
| 2557 |
stk::mesh::EntityId shellElemOwningProc[] = { 1 }; |
| 2558 |
|
| 2559 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 2560 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 2561 |
{ |
| 2562 |
{ 0, 5, 1 }, // proc 0 |
| 2563 |
{ 0, 6, 1 }, |
| 2564 |
{ 0, 7, 1 }, |
| 2565 |
{ 0, 8, 1 }, |
| 2566 |
{ 1, 5, 0 }, // proc 1 |
| 2567 |
{ 1, 6, 0 }, |
| 2568 |
{ 1, 7, 0 }, |
| 2569 |
{ 1, 8, 0 } |
| 2570 |
}; |
| 2571 |
|
| 2572 |
mesh.modification_begin(); |
| 2573 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 2574 |
if (hexElemOwningProc[i] == p_rank) { |
| 2575 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 2576 |
} |
| 2577 |
} |
| 2578 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 2579 |
if (shellElemOwningProc[i] == p_rank) { |
| 2580 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 2581 |
} |
| 2582 |
} |
| 2583 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs ); |
| 2584 |
mesh.modification_end(); |
| 2585 |
|
| 2586 |
ElemElemGraphTester elemElemGraph(mesh); |
| 2587 |
|
| 2588 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 2589 |
const Entity shell2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 2590 |
|
| 2591 |
if (p_rank == 0) { |
| 2592 |
// Connectivity for Hex Element 1 |
| 2593 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 2594 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2595 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 2596 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).side); |
| 2597 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).id); |
| 2598 |
EXPECT_EQ(1, elemElemGraph.get_owning_proc_id_of_remote_element(hex1, 0)); |
| 2599 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 2600 |
} |
| 2601 |
else if (p_rank == 1) { |
| 2602 |
// Connectivity for Shell Element 2 |
| 2603 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 2604 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2605 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(shell2)); |
| 2606 |
EXPECT_EQ(1, elemElemGraph.get_connected_remote_id_and_via_side(shell2, 0).side); |
| 2607 |
EXPECT_EQ(1u, elemElemGraph.get_connected_remote_id_and_via_side(shell2, 0).id); |
| 2608 |
EXPECT_EQ(0, elemElemGraph.get_owning_proc_id_of_remote_element(shell2, 0)); |
| 2609 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell2, 0)); |
| 2610 |
} |
| 2611 |
|
| 2612 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 2613 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2614 |
} |
| 2615 |
|
| 2616 |
TEST( ElementGraph, Hex0DelShell1Parallel ) |
| 2617 |
{ |
| 2618 |
// ID.proc |
| 2619 |
// |
| 2620 |
// 3.0------------7.0 |
| 2621 |
// /| /| |
| 2622 |
// / | / | |
| 2623 |
// / | / | |
| 2624 |
// 4.0------------8.0 | |
| 2625 |
// | | | | |
| 2626 |
// | | 1.0 |2.1| |
| 2627 |
// | | | | |
| 2628 |
// | 2.0---------|--6.0 |
| 2629 |
// | / | / |
| 2630 |
// | / | / |
| 2631 |
// |/ |/ |
| 2632 |
// 1.0------------5.0 |
| 2633 |
// ^ |
| 2634 |
// | |
| 2635 |
// ---- Deleted single shell element |
| 2636 |
|
| 2637 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 2638 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 2639 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 2640 |
|
| 2641 |
if(p_size != 2u) |
| 2642 |
{ |
| 2643 |
return; |
| 2644 |
} |
| 2645 |
|
| 2646 |
const unsigned spatialDim = 3; |
| 2647 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 2648 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 2649 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 2650 |
|
| 2651 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 2652 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 2653 |
meta.commit(); |
| 2654 |
|
| 2655 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 2656 |
{ 1, 2, 3, 4, 5, 6, 7, 8 } |
| 2657 |
}; |
| 2658 |
stk::mesh::EntityId hexElemIDs[] = { 1 }; |
| 2659 |
stk::mesh::EntityId hexElemOwningProc[] = { 0 }; |
| 2660 |
|
| 2661 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 2662 |
{ 5, 6, 7, 8 } |
| 2663 |
}; |
| 2664 |
stk::mesh::EntityId shellElemIDs[] = { 2 }; |
| 2665 |
stk::mesh::EntityId shellElemOwningProc[] = { 1 }; |
| 2666 |
|
| 2667 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 2668 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 2669 |
{ |
| 2670 |
{ 0, 5, 1 }, // proc 0 |
| 2671 |
{ 0, 6, 1 }, |
| 2672 |
{ 0, 7, 1 }, |
| 2673 |
{ 0, 8, 1 }, |
| 2674 |
{ 1, 5, 0 }, // proc 1 |
| 2675 |
{ 1, 6, 0 }, |
| 2676 |
{ 1, 7, 0 }, |
| 2677 |
{ 1, 8, 0 } |
| 2678 |
}; |
| 2679 |
|
| 2680 |
mesh.modification_begin(); |
| 2681 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 2682 |
if (hexElemOwningProc[i] == p_rank) { |
| 2683 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 2684 |
} |
| 2685 |
} |
| 2686 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 2687 |
if (shellElemOwningProc[i] == p_rank) { |
| 2688 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 2689 |
} |
| 2690 |
} |
| 2691 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs ); |
| 2692 |
mesh.modification_end(); |
| 2693 |
|
| 2694 |
ElemElemGraphTester elemElemGraph(mesh); |
| 2695 |
|
| 2696 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 2697 |
const Entity shell2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 2698 |
|
| 2699 |
stk::mesh::impl::DeletedElementInfoVector elements_to_delete; |
| 2700 |
if (p_rank == 1) { |
| 2701 |
elements_to_delete.push_back({shell2, 2, mesh.bucket(shell2).topology()}); |
| 2702 |
} |
| 2703 |
|
| 2704 |
elemElemGraph.delete_elements( elements_to_delete ); |
| 2705 |
|
| 2706 |
mesh.modification_begin(); |
| 2707 |
if (p_rank == 1) { |
| 2708 |
mesh.destroy_entity(shell2); |
| 2709 |
} |
| 2710 |
mesh.modification_end(); |
| 2711 |
|
| 2712 |
if (p_rank == 0) { |
| 2713 |
// Connectivity for Hex Element 1 |
| 2714 |
EXPECT_EQ(0u, elemElemGraph.num_edges()); |
| 2715 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 2716 |
EXPECT_EQ(0u, elemElemGraph.get_num_connected_elems(hex1)); |
| 2717 |
} |
| 2718 |
else if (p_rank == 1) { |
| 2719 |
EXPECT_EQ(0u, elemElemGraph.num_edges()); |
| 2720 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 2721 |
EXPECT_EQ(0u, elemElemGraph.size()); |
| 2722 |
} |
| 2723 |
|
| 2724 |
EXPECT_EQ(0u, elemElemGraph.num_edges()); |
| 2725 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 2726 |
} |
| 2727 |
|
| 2728 |
TEST( ElementGraph, Hex0AddShell1Parallel ) |
| 2729 |
{ |
| 2730 |
// ID.proc |
| 2731 |
// |
| 2732 |
// 3.0------------7.0 |
| 2733 |
// /| /| |
| 2734 |
// / | / | |
| 2735 |
// / | / | |
| 2736 |
// 4.0------------8.0 | |
| 2737 |
// | | | | |
| 2738 |
// | | 1.0 |2.1| |
| 2739 |
// | | | | |
| 2740 |
// | 2.0---------|--6.0 |
| 2741 |
// | / | / |
| 2742 |
// | / | / |
| 2743 |
// |/ |/ |
| 2744 |
// 1.0------------5.0 |
| 2745 |
// ^ |
| 2746 |
// | |
| 2747 |
// ---- Add a single shell element |
| 2748 |
|
| 2749 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 2750 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 2751 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 2752 |
|
| 2753 |
if(p_size != 2u) |
| 2754 |
{ |
| 2755 |
return; |
| 2756 |
} |
| 2757 |
|
| 2758 |
const unsigned spatialDim = 3; |
| 2759 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 2760 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 2761 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 2762 |
|
| 2763 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 2764 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 2765 |
meta.commit(); |
| 2766 |
|
| 2767 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 2768 |
{ 1, 2, 3, 4, 5, 6, 7, 8 } |
| 2769 |
}; |
| 2770 |
stk::mesh::EntityId hexElemIDs[] = { 1 }; |
| 2771 |
stk::mesh::EntityId hexElemOwningProc[] = { 0 }; |
| 2772 |
|
| 2773 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 2774 |
{ 5, 6, 7, 8 } |
| 2775 |
}; |
| 2776 |
stk::mesh::EntityId shellElemIDs[] = { 2 }; |
| 2777 |
stk::mesh::EntityId shellElemOwningProc[] = { 1 }; |
| 2778 |
|
| 2779 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 2780 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 2781 |
{ |
| 2782 |
{ 0, 5, 1 }, // proc 0 |
| 2783 |
{ 0, 6, 1 }, |
| 2784 |
{ 0, 7, 1 }, |
| 2785 |
{ 0, 8, 1 }, |
| 2786 |
{ 1, 5, 0 }, // proc 1 |
| 2787 |
{ 1, 6, 0 }, |
| 2788 |
{ 1, 7, 0 }, |
| 2789 |
{ 1, 8, 0 } |
| 2790 |
}; |
| 2791 |
|
| 2792 |
mesh.modification_begin(); |
| 2793 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 2794 |
if (hexElemOwningProc[i] == p_rank) { |
| 2795 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 2796 |
} |
| 2797 |
} |
| 2798 |
mesh.modification_end(); |
| 2799 |
|
| 2800 |
ElemElemGraphTester elemElemGraph(mesh); |
| 2801 |
|
| 2802 |
EXPECT_EQ(0u, elemElemGraph.num_edges()); |
| 2803 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 2804 |
|
| 2805 |
mesh.modification_begin(); |
| 2806 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 2807 |
if (shellElemOwningProc[i] == p_rank) { |
| 2808 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 2809 |
} |
| 2810 |
} |
| 2811 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs); |
| 2812 |
mesh.modification_end(); |
| 2813 |
|
| 2814 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 2815 |
const Entity shell2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 2816 |
|
| 2817 |
|
| 2818 |
stk::mesh::EntityVector elements_to_add; |
| 2819 |
if (p_rank == 1) { |
| 2820 |
elements_to_add.push_back(shell2); |
| 2821 |
} |
| 2822 |
elemElemGraph.add_elements(elements_to_add); |
| 2823 |
|
| 2824 |
if (p_rank == 0) { |
| 2825 |
// Connectivity for Hex Element 1 |
| 2826 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 2827 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2828 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 2829 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).side); |
| 2830 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).id); |
| 2831 |
EXPECT_EQ(1, elemElemGraph.get_owning_proc_id_of_remote_element(hex1, 0)); |
| 2832 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 2833 |
} |
| 2834 |
else if (p_rank == 1) { |
| 2835 |
// Connectivity for Shell Element 2 |
| 2836 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 2837 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2838 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(shell2)); |
| 2839 |
EXPECT_EQ(1, elemElemGraph.get_connected_remote_id_and_via_side(shell2, 0).side); |
| 2840 |
EXPECT_EQ(1u, elemElemGraph.get_connected_remote_id_and_via_side(shell2, 0).id); |
| 2841 |
EXPECT_EQ(0, elemElemGraph.get_owning_proc_id_of_remote_element(shell2, 0)); |
| 2842 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell2, 0)); |
| 2843 |
} |
| 2844 |
} |
| 2845 |
|
| 2846 |
|
| 2847 |
TEST( ElementGraph, Hex0AddShell0Hex1Parallel ) |
| 2848 |
{ |
| 2849 |
// ID.proc |
| 2850 |
// |
| 2851 |
// 3.0------------7.0-----------11.1 |
| 2852 |
// /| /| /| |
| 2853 |
// / | / | / | |
| 2854 |
// / | / | / | |
| 2855 |
// 4.0------------8.0-----------12.1 | |
| 2856 |
// | | | | | | |
| 2857 |
// | | 1.0 |3.0| 2.1 | | |
| 2858 |
// | | | | | | |
| 2859 |
// | 2.0---------|--6.0---------|-10.1 |
| 2860 |
// | / | / | / |
| 2861 |
// | / | / | / |
| 2862 |
// |/ |/ |/ |
| 2863 |
// 1.0------------5.0------------9.1 |
| 2864 |
// ^ |
| 2865 |
// | |
| 2866 |
// ---- Add a Single shell element here |
| 2867 |
// |
| 2868 |
// side 0 of the shell points right to element 2 |
| 2869 |
// side 1 of the shell points left to element 1 |
| 2870 |
|
| 2871 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 2872 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 2873 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 2874 |
|
| 2875 |
if(p_size != 2u) |
| 2876 |
{ |
| 2877 |
return; |
| 2878 |
} |
| 2879 |
|
| 2880 |
const unsigned spatialDim = 3; |
| 2881 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 2882 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 2883 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 2884 |
|
| 2885 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 2886 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 2887 |
meta.commit(); |
| 2888 |
|
| 2889 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 2890 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 2891 |
{ 5, 6, 7, 8, 9, 10, 11, 12 } |
| 2892 |
}; |
| 2893 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2 }; |
| 2894 |
stk::mesh::EntityId hexElemOwningProc[] = { 0, 1 }; |
| 2895 |
|
| 2896 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 2897 |
{ 5, 6, 7, 8 } |
| 2898 |
}; |
| 2899 |
stk::mesh::EntityId shellElemIDs[] = { 3 }; |
| 2900 |
stk::mesh::EntityId shellElemOwningProc[] = { 0 }; |
| 2901 |
|
| 2902 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 2903 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 2904 |
{ |
| 2905 |
{ 0, 5, 1 }, // proc 0 |
| 2906 |
{ 0, 6, 1 }, |
| 2907 |
{ 0, 7, 1 }, |
| 2908 |
{ 0, 8, 1 }, |
| 2909 |
{ 1, 5, 0 }, // proc 1 |
| 2910 |
{ 1, 6, 0 }, |
| 2911 |
{ 1, 7, 0 }, |
| 2912 |
{ 1, 8, 0 } |
| 2913 |
}; |
| 2914 |
|
| 2915 |
mesh.modification_begin(); |
| 2916 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 2917 |
if (hexElemOwningProc[i] == p_rank) { |
| 2918 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 2919 |
} |
| 2920 |
} |
| 2921 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs ); |
| 2922 |
mesh.modification_end(); |
| 2923 |
|
| 2924 |
|
| 2925 |
ElemElemGraphTester elemElemGraph(mesh); |
| 2926 |
|
| 2927 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 2928 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2929 |
|
| 2930 |
mesh.modification_begin(); |
| 2931 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 2932 |
if (shellElemOwningProc[i] == p_rank) { |
| 2933 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 2934 |
} |
| 2935 |
} |
| 2936 |
mesh.modification_end(); |
| 2937 |
|
| 2938 |
|
| 2939 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 2940 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 2941 |
const Entity shell3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 2942 |
|
| 2943 |
stk::mesh::EntityVector addVector; |
| 2944 |
if (0 == p_rank) { |
| 2945 |
addVector.push_back(shell3); |
| 2946 |
} |
| 2947 |
|
| 2948 |
elemElemGraph.add_elements(addVector); |
| 2949 |
|
| 2950 |
if (p_rank == 0) { |
| 2951 |
// Connectivity for Hex Element 1 |
| 2952 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 2953 |
expect_correct_connected_element_via_side(elemElemGraph, hex1, 0, shell3, 5); |
| 2954 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 2955 |
|
| 2956 |
// Connectivity for Shell Element 3 |
| 2957 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell3)); |
| 2958 |
expect_correct_connected_element_via_side(elemElemGraph, shell3, 0, hex1, 1); |
| 2959 |
EXPECT_EQ(0, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 1).side); |
| 2960 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 1).id); |
| 2961 |
EXPECT_TRUE (elemElemGraph.is_connected_elem_locally_owned(shell3, 0)); |
| 2962 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, 1)); |
| 2963 |
EXPECT_EQ(3u, elemElemGraph.num_edges()); |
| 2964 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2965 |
} |
| 2966 |
else if (p_rank == 1) { |
| 2967 |
// Connectivity for Hex Element 2 |
| 2968 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex2)); |
| 2969 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).side); |
| 2970 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).id); |
| 2971 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 2972 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 2973 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 2974 |
} |
| 2975 |
} |
| 2976 |
|
| 2977 |
TEST( ElementGraph, Hex0AddShell1Hex2Parallel ) |
| 2978 |
{ |
| 2979 |
// ID.proc |
| 2980 |
// |
| 2981 |
// 3.0------------7.0-----------11.2 |
| 2982 |
// /| /| /| |
| 2983 |
// / | / | / | |
| 2984 |
// / | / | / | |
| 2985 |
// 4.0------------8.0-----------12.2 | |
| 2986 |
// | | | | | | |
| 2987 |
// | | 1.0 |3.1| 2.2 | | |
| 2988 |
// | | | | | | |
| 2989 |
// | 2.0---------|--6.0---------|-10.2 |
| 2990 |
// | / | / | / |
| 2991 |
// | / | / | / |
| 2992 |
// |/ |/ |/ |
| 2993 |
// 1.0------------5.0------------9.2 |
| 2994 |
// ^ |
| 2995 |
// | |
| 2996 |
// ---- Add a Single shell element here |
| 2997 |
|
| 2998 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 2999 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 3000 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 3001 |
|
| 3002 |
if(p_size != 3u) |
| 3003 |
{ |
| 3004 |
return; |
| 3005 |
} |
| 3006 |
|
| 3007 |
const unsigned spatialDim = 3; |
| 3008 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 3009 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 3010 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 3011 |
|
| 3012 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 3013 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 3014 |
meta.commit(); |
| 3015 |
|
| 3016 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 3017 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 3018 |
{ 5, 6, 7, 8, 9, 10, 11, 12 } |
| 3019 |
}; |
| 3020 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2 }; |
| 3021 |
stk::mesh::EntityId hexElemOwningProc[] = { 0, 2 }; |
| 3022 |
|
| 3023 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 3024 |
{ 5, 6, 7, 8 } |
| 3025 |
}; |
| 3026 |
stk::mesh::EntityId shellElemIDs[] = { 3 }; |
| 3027 |
stk::mesh::EntityId shellElemOwningProc[] = { 1 }; |
| 3028 |
|
| 3029 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 3030 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 3031 |
{ |
| 3032 |
{ 0, 5, 1 }, // proc 0 |
| 3033 |
{ 0, 6, 1 }, |
| 3034 |
{ 0, 7, 1 }, |
| 3035 |
{ 0, 8, 1 }, |
| 3036 |
{ 0, 5, 2 }, // proc 0 |
| 3037 |
{ 0, 6, 2 }, |
| 3038 |
{ 0, 7, 2 }, |
| 3039 |
{ 0, 8, 2 }, |
| 3040 |
{ 1, 5, 0 }, // proc 1 |
| 3041 |
{ 1, 6, 0 }, |
| 3042 |
{ 1, 7, 0 }, |
| 3043 |
{ 1, 8, 0 }, |
| 3044 |
{ 1, 5, 2 }, |
| 3045 |
{ 1, 6, 2 }, |
| 3046 |
{ 1, 7, 2 }, |
| 3047 |
{ 1, 8, 2 }, |
| 3048 |
{ 2, 5, 1 }, // proc 2 |
| 3049 |
{ 2, 6, 1 }, |
| 3050 |
{ 2, 7, 1 }, |
| 3051 |
{ 2, 8, 1 }, |
| 3052 |
{ 2, 5, 0 }, // proc 2 |
| 3053 |
{ 2, 6, 0 }, |
| 3054 |
{ 2, 7, 0 }, |
| 3055 |
{ 2, 8, 0 } |
| 3056 |
}; |
| 3057 |
mesh.modification_begin(); |
| 3058 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 3059 |
if (hexElemOwningProc[i] == p_rank) { |
| 3060 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 3061 |
} |
| 3062 |
} |
| 3063 |
if (1 == p_rank) { |
| 3064 |
mesh.declare_node(5); |
| 3065 |
mesh.declare_node(6); |
| 3066 |
mesh.declare_node(7); |
| 3067 |
mesh.declare_node(8); |
| 3068 |
} |
| 3069 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs ); |
| 3070 |
mesh.modification_end(); |
| 3071 |
|
| 3072 |
ElemElemGraphTester elemElemGraph(mesh); |
| 3073 |
|
| 3074 |
if (0 == p_rank || 2 == p_rank) { |
| 3075 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3076 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3077 |
} |
| 3078 |
else { |
| 3079 |
EXPECT_EQ(0u, elemElemGraph.num_edges()); |
| 3080 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 3081 |
} |
| 3082 |
|
| 3083 |
mesh.modification_begin(); |
| 3084 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 3085 |
if (shellElemOwningProc[i] == p_rank) { |
| 3086 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 3087 |
} |
| 3088 |
} |
| 3089 |
mesh.modification_end(); |
| 3090 |
|
| 3091 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 3092 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 3093 |
const Entity shell3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 3094 |
|
| 3095 |
stk::mesh::EntityVector addVector; |
| 3096 |
if (1 == p_rank) { |
| 3097 |
addVector.push_back(shell3); |
| 3098 |
} |
| 3099 |
|
| 3100 |
elemElemGraph.add_elements(addVector); |
| 3101 |
|
| 3102 |
if (p_rank == 0) { |
| 3103 |
// Connectivity for Hex Element 1 |
| 3104 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 3105 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).side); |
| 3106 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).id); |
| 3107 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 3108 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3109 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3110 |
} |
| 3111 |
else if (p_rank == 1) { |
| 3112 |
// Connectivity for Shell Element 3 |
| 3113 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell3)); |
| 3114 |
EXPECT_EQ(1, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 0).side); |
| 3115 |
EXPECT_EQ(0, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 1).side); |
| 3116 |
EXPECT_EQ(1u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 0).id); |
| 3117 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 1).id); |
| 3118 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, 0)); |
| 3119 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, 1)); |
| 3120 |
EXPECT_EQ(2u, elemElemGraph.num_edges()); |
| 3121 |
EXPECT_EQ(2u, elemElemGraph.num_parallel_edges()); |
| 3122 |
} |
| 3123 |
else if (p_rank == 2) { |
| 3124 |
// Connectivity for Hex Element 2 |
| 3125 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex2)); |
| 3126 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).side); |
| 3127 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).id); |
| 3128 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 3129 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3130 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3131 |
} |
| 3132 |
} |
| 3133 |
|
| 3134 |
TEST( ElementGraph, Hex0Shell1AddHex2Parallel ) |
| 3135 |
{ |
| 3136 |
// ID.proc |
| 3137 |
// |
| 3138 |
// 3.0------------7.0-----------11.2 |
| 3139 |
// /| /| /| |
| 3140 |
// / | / | / | |
| 3141 |
// / | / | / | |
| 3142 |
// 4.0------------8.0-----------12.2 | |
| 3143 |
// | | | | | | |
| 3144 |
// | | 1.0 |3.1| 2.2 | | <-- Add this hex on the right |
| 3145 |
// | | | | | | |
| 3146 |
// | 2.0---------|--6.0---------|-10.2 |
| 3147 |
// | / | / | / |
| 3148 |
// | / | / | / |
| 3149 |
// |/ |/ |/ |
| 3150 |
// 1.0------------5.0------------9.2 |
| 3151 |
// ^ |
| 3152 |
// | |
| 3153 |
// ---- Single shell element here |
| 3154 |
|
| 3155 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 3156 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 3157 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 3158 |
|
| 3159 |
if(p_size != 3u) |
| 3160 |
{ |
| 3161 |
return; |
| 3162 |
} |
| 3163 |
|
| 3164 |
const unsigned spatialDim = 3; |
| 3165 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 3166 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 3167 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 3168 |
|
| 3169 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 3170 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 3171 |
meta.commit(); |
| 3172 |
|
| 3173 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 3174 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 3175 |
{ 5, 6, 7, 8, 9, 10, 11, 12 } |
| 3176 |
}; |
| 3177 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2 }; |
| 3178 |
stk::mesh::EntityId hexElemOwningProc[] = { 0, 2 }; |
| 3179 |
|
| 3180 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 3181 |
{ 5, 6, 7, 8 } |
| 3182 |
}; |
| 3183 |
stk::mesh::EntityId shellElemIDs[] = { 3 }; |
| 3184 |
stk::mesh::EntityId shellElemOwningProc[] = { 1 }; |
| 3185 |
|
| 3186 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 3187 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 3188 |
{ |
| 3189 |
{ 0, 5, 1 }, // proc 0 |
| 3190 |
{ 0, 6, 1 }, |
| 3191 |
{ 0, 7, 1 }, |
| 3192 |
{ 0, 8, 1 }, |
| 3193 |
{ 0, 5, 2 }, |
| 3194 |
{ 0, 6, 2 }, |
| 3195 |
{ 0, 7, 2 }, |
| 3196 |
{ 0, 8, 2 }, |
| 3197 |
{ 1, 5, 0 }, // proc 1 |
| 3198 |
{ 1, 6, 0 }, |
| 3199 |
{ 1, 7, 0 }, |
| 3200 |
{ 1, 8, 0 }, |
| 3201 |
{ 1, 5, 2 }, |
| 3202 |
{ 1, 6, 2 }, |
| 3203 |
{ 1, 7, 2 }, |
| 3204 |
{ 1, 8, 2 }, |
| 3205 |
{ 2, 5, 1 }, // proc 2 |
| 3206 |
{ 2, 6, 1 }, |
| 3207 |
{ 2, 7, 1 }, |
| 3208 |
{ 2, 8, 1 }, |
| 3209 |
{ 2, 5, 0 }, |
| 3210 |
{ 2, 6, 0 }, |
| 3211 |
{ 2, 7, 0 }, |
| 3212 |
{ 2, 8, 0 } |
| 3213 |
}; |
| 3214 |
mesh.modification_begin(); |
| 3215 |
if (hexElemOwningProc[0] == p_rank) { |
| 3216 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[0], hexNodeIDs[0]); |
| 3217 |
} |
| 3218 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 3219 |
if (shellElemOwningProc[i] == p_rank) { |
| 3220 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 3221 |
} |
| 3222 |
} |
| 3223 |
if (2 == p_rank) { |
| 3224 |
mesh.declare_node(5); |
| 3225 |
mesh.declare_node(6); |
| 3226 |
mesh.declare_node(7); |
| 3227 |
mesh.declare_node(8); |
| 3228 |
} |
| 3229 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs ); |
| 3230 |
mesh.modification_end(); |
| 3231 |
|
| 3232 |
ElemElemGraphTester elemElemGraph(mesh); |
| 3233 |
|
| 3234 |
if (0 == p_rank || 1 == p_rank) { |
| 3235 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3236 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3237 |
} |
| 3238 |
else { |
| 3239 |
EXPECT_EQ(0u, elemElemGraph.num_edges()); |
| 3240 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 3241 |
} |
| 3242 |
|
| 3243 |
mesh.modification_begin(); |
| 3244 |
if (hexElemOwningProc[1] == p_rank) { |
| 3245 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[1], hexNodeIDs[1]); |
| 3246 |
} |
| 3247 |
mesh.modification_end(); |
| 3248 |
|
| 3249 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 3250 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 3251 |
const Entity shell3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 3252 |
|
| 3253 |
stk::mesh::EntityVector addVector; |
| 3254 |
if (2 == p_rank) { |
| 3255 |
addVector.push_back(hex2); |
| 3256 |
} |
| 3257 |
|
| 3258 |
elemElemGraph.add_elements(addVector); |
| 3259 |
|
| 3260 |
if (p_rank == 0) { |
| 3261 |
// Connectivity for Hex Element 1 |
| 3262 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 3263 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).side); |
| 3264 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).id); |
| 3265 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 3266 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3267 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3268 |
} |
| 3269 |
else if (p_rank == 1) { |
| 3270 |
// Connectivity for Shell Element 3 |
| 3271 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell3)); |
| 3272 |
EXPECT_EQ(1, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 0).side); |
| 3273 |
EXPECT_EQ(0, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 1).side); |
| 3274 |
EXPECT_EQ(1u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 0).id); |
| 3275 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 1).id); |
| 3276 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, 0)); |
| 3277 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, 1)); |
| 3278 |
EXPECT_EQ(2u, elemElemGraph.num_edges()); |
| 3279 |
EXPECT_EQ(2u, elemElemGraph.num_parallel_edges()); |
| 3280 |
} |
| 3281 |
else if (p_rank == 2) { |
| 3282 |
// Connectivity for Hex Element 2 |
| 3283 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex2)); |
| 3284 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).side); |
| 3285 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).id); |
| 3286 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 3287 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3288 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3289 |
} |
| 3290 |
} |
| 3291 |
|
| 3292 |
TEST( ElementGraph, AdjacentHex0Shell1Parallel ) |
| 3293 |
{ |
| 3294 |
// ID.proc |
| 3295 |
// |
| 3296 |
// 12.0-----------11.0 |
| 3297 |
// /| /| |
| 3298 |
// / | / | |
| 3299 |
// / | / | |
| 3300 |
// 9.0-----------10.0 | |
| 3301 |
// | | | | |
| 3302 |
// | | 2.0 |4.1| |
| 3303 |
// | | | | |
| 3304 |
// | 8.0---------|--7.0 |
| 3305 |
// | /| | /| |
| 3306 |
// | / | | / | |
| 3307 |
// |/ | |/ | |
| 3308 |
// 5.0------------6.0 | |
| 3309 |
// | | | | |
| 3310 |
// | | 1.0 |3.1| |
| 3311 |
// | | | | |
| 3312 |
// | 4.0---------|--3.0 |
| 3313 |
// | / | / |
| 3314 |
// | / | / |
| 3315 |
// |/ |/ |
| 3316 |
// 1.0------------2.0 |
| 3317 |
// ^ |
| 3318 |
// | |
| 3319 |
// ---- Two adjacent shell elements |
| 3320 |
|
| 3321 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 3322 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 3323 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 3324 |
|
| 3325 |
if(p_size != 2u) |
| 3326 |
{ |
| 3327 |
GTEST_SKIP(); |
| 3328 |
} |
| 3329 |
|
| 3330 |
const unsigned spatialDim = 3; |
| 3331 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 3332 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 3333 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 3334 |
|
| 3335 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 3336 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 3337 |
meta.commit(); |
| 3338 |
|
| 3339 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 3340 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 3341 |
{ 5, 6, 7, 8, 9, 10, 11, 12 } |
| 3342 |
}; |
| 3343 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2 }; |
| 3344 |
stk::mesh::EntityId hexElemOwningProc[] = { 0, 0 }; |
| 3345 |
|
| 3346 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 3347 |
{ 2, 3, 7, 6 }, |
| 3348 |
{ 6, 7, 11, 10 } |
| 3349 |
}; |
| 3350 |
stk::mesh::EntityId shellElemIDs[] = { 3, 4 }; |
| 3351 |
stk::mesh::EntityId shellElemOwningProc[] = { 1, 1 }; |
| 3352 |
|
| 3353 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 3354 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 3355 |
{ |
| 3356 |
{ 0, 2, 1 }, // proc 0 |
| 3357 |
{ 0, 3, 1 }, |
| 3358 |
{ 0, 7, 1 }, |
| 3359 |
{ 0, 6, 1 }, |
| 3360 |
{ 0, 11, 1 }, |
| 3361 |
{ 0, 10, 1 }, |
| 3362 |
{ 1, 2, 0 }, // proc 1 |
| 3363 |
{ 1, 3, 0 }, |
| 3364 |
{ 1, 7, 0 }, |
| 3365 |
{ 1, 6, 0 }, |
| 3366 |
{ 1, 11, 0 }, |
| 3367 |
{ 1, 10, 0 } |
| 3368 |
}; |
| 3369 |
|
| 3370 |
mesh.modification_begin(); |
| 3371 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 3372 |
if (hexElemOwningProc[i] == p_rank) { |
| 3373 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 3374 |
} |
| 3375 |
} |
| 3376 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 3377 |
if (shellElemOwningProc[i] == p_rank) { |
| 3378 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 3379 |
} |
| 3380 |
} |
| 3381 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs ); |
| 3382 |
mesh.modification_end(); |
| 3383 |
|
| 3384 |
ElemElemGraphTester elemElemGraph(mesh); |
| 3385 |
|
| 3386 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 3387 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 3388 |
const Entity shell3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 3389 |
const Entity shell4 = mesh.get_entity(stk::topology::ELEM_RANK, 4); |
| 3390 |
|
| 3391 |
if (p_rank == 0u) { |
| 3392 |
// Connectivity for Hex Element 1 |
| 3393 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(hex1)); |
| 3394 |
expect_correct_connected_element_via_side(elemElemGraph, hex1, 0, hex2, 5); |
| 3395 |
EXPECT_EQ(1, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 1).side); |
| 3396 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 1).id); |
| 3397 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 3398 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex1, 1)); |
| 3399 |
|
| 3400 |
// Connectivity for Hex Element 2 |
| 3401 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(hex2)); |
| 3402 |
expect_correct_connected_element_via_side(elemElemGraph, hex2, 0, hex1, 4); |
| 3403 |
EXPECT_EQ(1, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 1).side); |
| 3404 |
EXPECT_EQ(4u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 1).id); |
| 3405 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 3406 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 1)); |
| 3407 |
EXPECT_EQ(4u, elemElemGraph.num_edges()); |
| 3408 |
EXPECT_EQ(2u, elemElemGraph.num_parallel_edges()); |
| 3409 |
} |
| 3410 |
else if (p_rank == 1u) { |
| 3411 |
// Connectivity for Shell Element 3: 2 graph edges ... remote: 0, local: 1 |
| 3412 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell3)); |
| 3413 |
EXPECT_EQ(1, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 0).side); |
| 3414 |
EXPECT_EQ(1u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 0).id); |
| 3415 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, 0)); |
| 3416 |
expect_correct_connected_element_via_side(elemElemGraph, shell3, 1, shell4, 4); // edge |
| 3417 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(shell3, 1)); // connected to shell4 through edge |
| 3418 |
|
| 3419 |
// Connectivity for Shell Element 4: 2 graph edges .. local: 0, remote: 1 |
| 3420 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell4)); |
| 3421 |
EXPECT_EQ(1, elemElemGraph.get_connected_remote_id_and_via_side(shell4, 1).side); |
| 3422 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(shell4, 1).id); |
| 3423 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell4, 1)); |
| 3424 |
expect_correct_connected_element_via_side(elemElemGraph, shell4, 0, shell3, 2); // edge |
| 3425 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(shell4, 0)); // connected to shell3 through edge |
| 3426 |
|
| 3427 |
EXPECT_EQ(4u, elemElemGraph.num_edges()); |
| 3428 |
EXPECT_EQ(2u, elemElemGraph.num_parallel_edges()); |
| 3429 |
} |
| 3430 |
|
| 3431 |
EXPECT_EQ(0u, elemElemGraph.num_coincident_edges()); |
| 3432 |
} |
| 3433 |
|
| 3434 |
|
| 3435 |
TEST( ElementGraph, Hex0Shell0Hex1Parallel ) |
| 3436 |
{ |
| 3437 |
// ID.proc |
| 3438 |
// |
| 3439 |
// 3.0------------7.0-----------11.1 |
| 3440 |
// /| /| /| |
| 3441 |
// / | / | / | |
| 3442 |
// / | / | / | |
| 3443 |
// 4.0------------8.0-----------12.1 | |
| 3444 |
// | | | | | | |
| 3445 |
// | | 1.0 |3.0| 2.1 | | |
| 3446 |
// | | | | | | |
| 3447 |
// | 2.0---------|--6.0---------|-10.1 |
| 3448 |
// | / | / | / |
| 3449 |
// | / | / | / |
| 3450 |
// |/ |/ |/ |
| 3451 |
// 1.0------------5.0------------9.1 |
| 3452 |
// ^ |
| 3453 |
// | |
| 3454 |
// ---- Single shell element |
| 3455 |
|
| 3456 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 3457 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 3458 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 3459 |
|
| 3460 |
if(p_size != 2u) |
| 3461 |
{ |
| 3462 |
return; |
| 3463 |
} |
| 3464 |
|
| 3465 |
const unsigned spatialDim = 3; |
| 3466 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 3467 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 3468 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 3469 |
|
| 3470 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 3471 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 3472 |
meta.commit(); |
| 3473 |
|
| 3474 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 3475 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 3476 |
{ 5, 6, 7, 8, 9, 10, 11, 12 } |
| 3477 |
}; |
| 3478 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2 }; |
| 3479 |
stk::mesh::EntityId hexElemOwningProc[] = { 0, 1 }; |
| 3480 |
|
| 3481 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 3482 |
{ 5, 6, 7, 8 } |
| 3483 |
}; |
| 3484 |
stk::mesh::EntityId shellElemIDs[] = { 3 }; |
| 3485 |
stk::mesh::EntityId shellElemOwningProc[] = { 0 }; |
| 3486 |
|
| 3487 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 3488 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 3489 |
{ |
| 3490 |
{ 0, 5, 1 }, // proc 0 |
| 3491 |
{ 0, 6, 1 }, |
| 3492 |
{ 0, 7, 1 }, |
| 3493 |
{ 0, 8, 1 }, |
| 3494 |
{ 1, 5, 0 }, // proc 1 |
| 3495 |
{ 1, 6, 0 }, |
| 3496 |
{ 1, 7, 0 }, |
| 3497 |
{ 1, 8, 0 } |
| 3498 |
}; |
| 3499 |
|
| 3500 |
mesh.modification_begin(); |
| 3501 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 3502 |
if (hexElemOwningProc[i] == p_rank) { |
| 3503 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 3504 |
} |
| 3505 |
} |
| 3506 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 3507 |
if (shellElemOwningProc[i] == p_rank) { |
| 3508 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 3509 |
} |
| 3510 |
} |
| 3511 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs ); |
| 3512 |
mesh.modification_end(); |
| 3513 |
|
| 3514 |
ElemElemGraphTester elemElemGraph(mesh); |
| 3515 |
|
| 3516 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 3517 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 3518 |
const Entity shell3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 3519 |
|
| 3520 |
if (p_rank == 0) { |
| 3521 |
{ |
| 3522 |
// Connectivity for Hex Element 1 |
| 3523 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 3524 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex1, 0); |
| 3525 |
EXPECT_EQ(5, elem_via_side.side); |
| 3526 |
EXPECT_EQ(shell3, elem_via_side.element); |
| 3527 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 3528 |
} |
| 3529 |
{ |
| 3530 |
// Connectivity for Shell Element 3 |
| 3531 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell3)); |
| 3532 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(shell3, 0); |
| 3533 |
EXPECT_EQ(1, elem_via_side.side); |
| 3534 |
EXPECT_EQ(hex1, elem_via_side.element); |
| 3535 |
EXPECT_EQ(0, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 1).side); |
| 3536 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, 1).id); |
| 3537 |
EXPECT_TRUE (elemElemGraph.is_connected_elem_locally_owned(shell3, 0)); |
| 3538 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, 1)); |
| 3539 |
EXPECT_EQ(3u, elemElemGraph.num_edges()); |
| 3540 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3541 |
} |
| 3542 |
} |
| 3543 |
else if (p_rank == 1) { |
| 3544 |
// Connectivity for Hex Element 2 |
| 3545 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex2)); |
| 3546 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).side); |
| 3547 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).id); |
| 3548 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 3549 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3550 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3551 |
} |
| 3552 |
} |
| 3553 |
|
| 3554 |
class HexShellHexMesh { |
| 3555 |
public: |
| 3556 |
virtual ~HexShellHexMesh(){} |
| 3557 |
HexShellHexMesh(MPI_Comm comm, const std::vector<int>& hexOwningProcs, const std::vector<int>& shellOwningProcs, |
| 3558 |
const std::vector<std::vector<unsigned> >& sharedNodesAndProcs) |
| 3559 |
: meshPtr(build_mesh(3, comm, stk::mesh::BulkData::NO_AUTO_AURA)), mesh(*meshPtr), meta(mesh.mesh_meta_data()) |
| 3560 |
{ |
| 3561 |
// ID.proc |
| 3562 |
// |
| 3563 |
// 3.0------------7.0-----------11.1 |
| 3564 |
// /| /| /| |
| 3565 |
// / | / | / | |
| 3566 |
// / | / | / | |
| 3567 |
// 4.0------------8.0-----------12.1 | |
| 3568 |
// | | | | | | |
| 3569 |
// | | 1 | 3 | 2 | | |
| 3570 |
// | | | | | | |
| 3571 |
// | 2.0---------|--6.0---------|-10.1 |
| 3572 |
// | / | / | / |
| 3573 |
// | / | / | / |
| 3574 |
// |/ |/ |/ |
| 3575 |
// 1.0------------5.0------------9.1 |
| 3576 |
|
| 3577 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 3578 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 3579 |
meta.commit(); |
| 3580 |
|
| 3581 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 3582 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 3583 |
{ 5, 6, 7, 8, 9, 10, 11, 12 } |
| 3584 |
}; |
| 3585 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2 }; |
| 3586 |
|
| 3587 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 3588 |
{ 5, 6, 7, 8 } |
| 3589 |
}; |
| 3590 |
stk::mesh::EntityId shellElemIDs[] = { 3 }; |
| 3591 |
|
| 3592 |
mesh.modification_begin(); |
| 3593 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 3594 |
if (hexOwningProcs[i] == mesh.parallel_rank()) { |
| 3595 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 3596 |
} |
| 3597 |
} |
| 3598 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 3599 |
if (shellOwningProcs[i] == mesh.parallel_rank()) { |
| 3600 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 3601 |
} |
| 3602 |
} |
| 3603 |
setup_node_sharing(mesh, sharedNodesAndProcs ); |
| 3604 |
mesh.modification_end(); |
| 3605 |
|
| 3606 |
mesh.initialize_face_adjacent_element_graph(); |
| 3607 |
} |
| 3608 |
|
| 3609 |
stk::mesh::BulkData& get_bulk() { return mesh; } |
| 3610 |
|
| 3611 |
private: |
| 3612 |
std::shared_ptr<stk::mesh::BulkData> meshPtr; |
| 3613 |
stk::mesh::BulkData& mesh; |
| 3614 |
stk::mesh::MetaData& meta; |
| 3615 |
}; |
| 3616 |
|
| 3617 |
TEST( ElementGraph, HexDelShellHexSerial ) |
| 3618 |
{ |
| 3619 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 3620 |
int p_size = stk::parallel_machine_size(pm); |
| 3621 |
|
| 3622 |
if(p_size > 1) |
| 3623 |
{ |
| 3624 |
return; |
| 3625 |
} |
| 3626 |
|
| 3627 |
std::vector<int> hexElemOwningProc = {0, 0}; |
| 3628 |
std::vector<int> shellElemOwningProc = {0}; |
| 3629 |
std::vector<std::vector<unsigned> > sharedNodeIDsAndProcs = {}; |
| 3630 |
|
| 3631 |
HexShellHexMesh mesh(pm, hexElemOwningProc, shellElemOwningProc, sharedNodeIDsAndProcs); |
| 3632 |
|
| 3633 |
const Entity hex1 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 1); |
| 3634 |
const Entity hex2 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 2); |
| 3635 |
const Entity shell3 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 3); |
| 3636 |
|
| 3637 |
mesh.get_bulk().modification_begin(); |
| 3638 |
mesh.get_bulk().destroy_entity(shell3); |
| 3639 |
mesh.get_bulk().destroy_entity(hex2); |
| 3640 |
EXPECT_NO_THROW(mesh.get_bulk().modification_end()); |
| 3641 |
|
| 3642 |
ElemElemGraph& elemElemGraph = mesh.get_bulk().get_face_adjacent_element_graph(); |
| 3643 |
// Connectivity for Hex Element 1 |
| 3644 |
EXPECT_EQ(0u, elemElemGraph.get_num_connected_elems(hex1)); |
| 3645 |
|
| 3646 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 3647 |
} |
| 3648 |
|
| 3649 |
TEST( ElementGraph, Hex0DelShell0DelHex1Parallel ) |
| 3650 |
{ |
| 3651 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 3652 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 3653 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 3654 |
|
| 3655 |
if(p_size != 2u) |
| 3656 |
{ |
| 3657 |
return; |
| 3658 |
} |
| 3659 |
|
| 3660 |
std::vector<int> hexElemOwningProc = {0, 1}; |
| 3661 |
std::vector<int> shellElemOwningProc = {0}; |
| 3662 |
std::vector<std::vector<unsigned> > sharedNodeIDsAndProcs = |
| 3663 |
{ |
| 3664 |
{ 0, 5, 1 }, // proc 0 |
| 3665 |
{ 0, 6, 1 }, |
| 3666 |
{ 0, 7, 1 }, |
| 3667 |
{ 0, 8, 1 }, |
| 3668 |
{ 1, 5, 0 }, // proc 1 |
| 3669 |
{ 1, 6, 0 }, |
| 3670 |
{ 1, 7, 0 }, |
| 3671 |
{ 1, 8, 0 } |
| 3672 |
}; |
| 3673 |
|
| 3674 |
|
| 3675 |
HexShellHexMesh mesh(pm, hexElemOwningProc, shellElemOwningProc, sharedNodeIDsAndProcs); |
| 3676 |
|
| 3677 |
const Entity hex1 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 1); |
| 3678 |
const Entity hex2 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 2); |
| 3679 |
const Entity shell3 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 3); |
| 3680 |
|
| 3681 |
mesh.get_bulk().modification_begin(); |
| 3682 |
if (p_rank == 0) { |
| 3683 |
mesh.get_bulk().destroy_entity(shell3); |
| 3684 |
} |
| 3685 |
else if (p_rank == 1) { |
| 3686 |
mesh.get_bulk().destroy_entity(hex2); |
| 3687 |
} |
| 3688 |
EXPECT_NO_THROW(mesh.get_bulk().modification_end()); |
| 3689 |
|
| 3690 |
ElemElemGraph& elemElemGraph = mesh.get_bulk().get_face_adjacent_element_graph(); |
| 3691 |
if (p_rank == 0) { |
| 3692 |
// Connectivity for Hex Element 1 |
| 3693 |
EXPECT_EQ(0u, elemElemGraph.get_num_connected_elems(hex1)); |
| 3694 |
EXPECT_EQ(1u, elemElemGraph.size()); |
| 3695 |
} |
| 3696 |
else if (p_rank == 1) { |
| 3697 |
EXPECT_EQ(0u, elemElemGraph.size()); |
| 3698 |
} |
| 3699 |
} |
| 3700 |
|
| 3701 |
TEST( ElementGraph, Hex0DelShell1Hex2Parallel ) |
| 3702 |
{ |
| 3703 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 3704 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 3705 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 3706 |
|
| 3707 |
if(p_size != 3u) |
| 3708 |
{ |
| 3709 |
return; |
| 3710 |
} |
| 3711 |
|
| 3712 |
std::vector<int> hexElemOwningProc = {0, 2}; |
| 3713 |
std::vector<int> shellElemOwningProc = {1}; |
| 3714 |
std::vector<std::vector<unsigned> > sharedNodeIDsAndProcs = |
| 3715 |
{ |
| 3716 |
{ 0, 5, 1 }, // proc 0 |
| 3717 |
{ 0, 6, 1 }, |
| 3718 |
{ 0, 7, 1 }, |
| 3719 |
{ 0, 8, 1 }, |
| 3720 |
{ 0, 5, 2 }, |
| 3721 |
{ 0, 6, 2 }, |
| 3722 |
{ 0, 7, 2 }, |
| 3723 |
{ 0, 8, 2 }, |
| 3724 |
{ 1, 5, 0 }, // proc 1 |
| 3725 |
{ 1, 6, 0 }, |
| 3726 |
{ 1, 7, 0 }, |
| 3727 |
{ 1, 8, 0 }, |
| 3728 |
{ 1, 5, 2 }, |
| 3729 |
{ 1, 6, 2 }, |
| 3730 |
{ 1, 7, 2 }, |
| 3731 |
{ 1, 8, 2 }, |
| 3732 |
{ 2, 5, 0 }, // proc 2 |
| 3733 |
{ 2, 6, 0 }, |
| 3734 |
{ 2, 7, 0 }, |
| 3735 |
{ 2, 8, 0 }, |
| 3736 |
{ 2, 5, 1 }, |
| 3737 |
{ 2, 6, 1 }, |
| 3738 |
{ 2, 7, 1 }, |
| 3739 |
{ 2, 8, 1 } |
| 3740 |
}; |
| 3741 |
|
| 3742 |
|
| 3743 |
HexShellHexMesh mesh(pm, hexElemOwningProc, shellElemOwningProc, sharedNodeIDsAndProcs); |
| 3744 |
|
| 3745 |
ElemElemGraphTester elemElemGraph(mesh.get_bulk()); |
| 3746 |
|
| 3747 |
const Entity hex1 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 1); |
| 3748 |
const Entity hex2 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 2); |
| 3749 |
const Entity shell3 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 3); |
| 3750 |
|
| 3751 |
stk::mesh::impl::DeletedElementInfoVector elements_to_delete; |
| 3752 |
if (p_rank == 1) { |
| 3753 |
elements_to_delete.push_back({shell3, 3, mesh.get_bulk().bucket(shell3).topology()}); |
| 3754 |
} |
| 3755 |
|
| 3756 |
elemElemGraph.delete_elements( elements_to_delete ); |
| 3757 |
|
| 3758 |
mesh.get_bulk().modification_begin(); |
| 3759 |
if (p_rank == 1) { |
| 3760 |
mesh.get_bulk().destroy_entity(shell3); |
| 3761 |
} |
| 3762 |
mesh.get_bulk().modification_end(); |
| 3763 |
|
| 3764 |
if (p_rank == 0) { |
| 3765 |
// Connectivity for Hex Element 1 |
| 3766 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3767 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3768 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 3769 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).side); |
| 3770 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).id); |
| 3771 |
EXPECT_EQ(2, elemElemGraph.get_owning_proc_id_of_remote_element(hex1, 0)); |
| 3772 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 3773 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3774 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3775 |
} |
| 3776 |
else if (p_rank == 1) { |
| 3777 |
// Connectivity for Shell Element 3 |
| 3778 |
EXPECT_EQ(0u, elemElemGraph.num_edges()); |
| 3779 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 3780 |
EXPECT_EQ(0u, elemElemGraph.size()); |
| 3781 |
EXPECT_EQ(0u, elemElemGraph.num_edges()); |
| 3782 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 3783 |
} |
| 3784 |
else if (p_rank == 2) { |
| 3785 |
// Connectivity for Hex Element 2 |
| 3786 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3787 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3788 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex2)); |
| 3789 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).side); |
| 3790 |
EXPECT_EQ(1u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).id); |
| 3791 |
EXPECT_EQ(0, elemElemGraph.get_owning_proc_id_of_remote_element(hex2, 0)); |
| 3792 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 3793 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3794 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3795 |
} |
| 3796 |
elemElemGraph.write_graph(std::cerr); |
| 3797 |
} |
| 3798 |
|
| 3799 |
TEST( ElementGraph, Hex0Shell1Hex2Parallel ) |
| 3800 |
{ |
| 3801 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 3802 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 3803 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 3804 |
|
| 3805 |
if(p_size != 3u) |
| 3806 |
{ |
| 3807 |
return; |
| 3808 |
} |
| 3809 |
|
| 3810 |
std::vector<int> hexElemOwningProc = {0, 2}; |
| 3811 |
std::vector<int> shellElemOwningProc = {1}; |
| 3812 |
std::vector<std::vector<unsigned> > sharedNodeIDsAndProcs = |
| 3813 |
{ |
| 3814 |
{ 0, 5, 1 }, // proc 0 |
| 3815 |
{ 0, 6, 1 }, |
| 3816 |
{ 0, 7, 1 }, |
| 3817 |
{ 0, 8, 1 }, |
| 3818 |
{ 0, 5, 2 }, |
| 3819 |
{ 0, 6, 2 }, |
| 3820 |
{ 0, 7, 2 }, |
| 3821 |
{ 0, 8, 2 }, |
| 3822 |
{ 1, 5, 0 }, // proc 1 |
| 3823 |
{ 1, 6, 0 }, |
| 3824 |
{ 1, 7, 0 }, |
| 3825 |
{ 1, 8, 0 }, |
| 3826 |
{ 1, 5, 2 }, |
| 3827 |
{ 1, 6, 2 }, |
| 3828 |
{ 1, 7, 2 }, |
| 3829 |
{ 1, 8, 2 }, |
| 3830 |
{ 2, 5, 0 }, // proc 2 |
| 3831 |
{ 2, 6, 0 }, |
| 3832 |
{ 2, 7, 0 }, |
| 3833 |
{ 2, 8, 0 }, |
| 3834 |
{ 2, 5, 1 }, |
| 3835 |
{ 2, 6, 1 }, |
| 3836 |
{ 2, 7, 1 }, |
| 3837 |
{ 2, 8, 1 } |
| 3838 |
}; |
| 3839 |
|
| 3840 |
|
| 3841 |
HexShellHexMesh mesh(pm, hexElemOwningProc, shellElemOwningProc, sharedNodeIDsAndProcs); |
| 3842 |
|
| 3843 |
ElemElemGraphTester elemElemGraph(mesh.get_bulk()); |
| 3844 |
|
| 3845 |
const Entity hex1 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 1); |
| 3846 |
const Entity hex2 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 2); |
| 3847 |
const Entity shell3 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 3); |
| 3848 |
|
| 3849 |
if (p_rank == 0) { |
| 3850 |
// Connectivity for Hex Element 1 |
| 3851 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 3852 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).side); |
| 3853 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).id); |
| 3854 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 3855 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3856 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3857 |
} |
| 3858 |
else if (p_rank == 1) { |
| 3859 |
// Connectivity for Shell Element 3 |
| 3860 |
unsigned hex1Index = 0; |
| 3861 |
unsigned hex2Index = 1; |
| 3862 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell3)); |
| 3863 |
EXPECT_EQ(0, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex2Index).side); |
| 3864 |
EXPECT_EQ(1, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex1Index).side); |
| 3865 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex2Index).id); |
| 3866 |
EXPECT_EQ(1u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex1Index).id); |
| 3867 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, hex2Index)); |
| 3868 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, hex1Index)); |
| 3869 |
EXPECT_EQ(2u, elemElemGraph.num_edges()); |
| 3870 |
EXPECT_EQ(2u, elemElemGraph.num_parallel_edges()); |
| 3871 |
} |
| 3872 |
else if (p_rank == 2) { |
| 3873 |
// Connectivity for Hex Element 2 |
| 3874 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex2)); |
| 3875 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).side); |
| 3876 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).id); |
| 3877 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 3878 |
EXPECT_EQ(1u, elemElemGraph.num_edges()); |
| 3879 |
EXPECT_EQ(1u, elemElemGraph.num_parallel_edges()); |
| 3880 |
} |
| 3881 |
} |
| 3882 |
|
| 3883 |
TEST( ElementGraph, Hex0Shell1Hex0Parallel ) |
| 3884 |
{ |
| 3885 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 3886 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 3887 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 3888 |
|
| 3889 |
if(p_size != 2u) |
| 3890 |
{ |
| 3891 |
return; |
| 3892 |
} |
| 3893 |
|
| 3894 |
std::vector<int> hexElemOwningProc = {0, 0}; |
| 3895 |
std::vector<int> shellElemOwningProc = {1}; |
| 3896 |
std::vector<std::vector<unsigned> > sharedNodeIDsAndProcs = |
| 3897 |
{ |
| 3898 |
{ 0, 5, 1 }, // proc 0 |
| 3899 |
{ 0, 6, 1 }, |
| 3900 |
{ 0, 7, 1 }, |
| 3901 |
{ 0, 8, 1 }, |
| 3902 |
{ 1, 5, 0 }, // proc 1 |
| 3903 |
{ 1, 6, 0 }, |
| 3904 |
{ 1, 7, 0 }, |
| 3905 |
{ 1, 8, 0 } |
| 3906 |
}; |
| 3907 |
|
| 3908 |
|
| 3909 |
HexShellHexMesh mesh(pm, hexElemOwningProc, shellElemOwningProc, sharedNodeIDsAndProcs); |
| 3910 |
|
| 3911 |
ElemElemGraphTester elemElemGraph(mesh.get_bulk()); |
| 3912 |
|
| 3913 |
const Entity hex1 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 1); |
| 3914 |
const Entity hex2 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 2); |
| 3915 |
const Entity shell3 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 3); |
| 3916 |
|
| 3917 |
if (p_rank == 0) { |
| 3918 |
// Connectivity for Hex Element 1 |
| 3919 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 3920 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).side); |
| 3921 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).id); |
| 3922 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 3923 |
|
| 3924 |
// Connectivity for Hex Element 2 |
| 3925 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex2)); |
| 3926 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).side); |
| 3927 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).id); |
| 3928 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 3929 |
} |
| 3930 |
else if (p_rank == 1) { |
| 3931 |
// Connectivity for Shell Element 3 |
| 3932 |
unsigned hex1Index = 0; |
| 3933 |
unsigned hex2Index = 1; |
| 3934 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell3)); |
| 3935 |
EXPECT_EQ(0, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex2Index).side); |
| 3936 |
EXPECT_EQ(1, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex1Index).side); |
| 3937 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex2Index).id); |
| 3938 |
EXPECT_EQ(1u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex1Index).id); |
| 3939 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, hex2Index)); |
| 3940 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, hex1Index)); |
| 3941 |
} |
| 3942 |
|
| 3943 |
EXPECT_EQ(2u, elemElemGraph.num_edges()); |
| 3944 |
EXPECT_EQ(2u, elemElemGraph.num_parallel_edges()); |
| 3945 |
} |
| 3946 |
|
| 3947 |
TEST( ElementGraph, Hex0AddShell1Hex0Parallel ) |
| 3948 |
{ |
| 3949 |
// ID.proc |
| 3950 |
// |
| 3951 |
// 3.0------------7.0-----------11.0 |
| 3952 |
// /| /| /| |
| 3953 |
// / | / | / | |
| 3954 |
// / | / | / | |
| 3955 |
// 4.0------------8.0-----------12.0 | |
| 3956 |
// | | | | | | |
| 3957 |
// | | 1.0 |3.1| 2.0 | | |
| 3958 |
// | | | | | | |
| 3959 |
// | 2.0---------|--6.0---------|-10.0 |
| 3960 |
// | / | / | / |
| 3961 |
// | / | / | / |
| 3962 |
// |/ |/ |/ |
| 3963 |
// 1.0------------5.0------------9.0 |
| 3964 |
// ^ |
| 3965 |
// | |
| 3966 |
// ---- Single shell element |
| 3967 |
|
| 3968 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 3969 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 3970 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 3971 |
|
| 3972 |
if(p_size != 2u) |
| 3973 |
{ |
| 3974 |
return; |
| 3975 |
} |
| 3976 |
|
| 3977 |
const unsigned spatialDim = 3; |
| 3978 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, pm); |
| 3979 |
stk::mesh::BulkData& mesh = *bulkPtr; |
| 3980 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 3981 |
|
| 3982 |
stk::mesh::Part * hexPart = &meta.declare_part_with_topology("hex_part", stk::topology::HEX_8); |
| 3983 |
stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_QUAD_4); |
| 3984 |
meta.commit(); |
| 3985 |
|
| 3986 |
std::vector<stk::mesh::EntityIdVector> hexNodeIDs { |
| 3987 |
{ 1, 2, 3, 4, 5, 6, 7, 8 }, |
| 3988 |
{ 5, 6, 7, 8, 9, 10, 11, 12 } |
| 3989 |
}; |
| 3990 |
stk::mesh::EntityId hexElemIDs[] = { 1, 2 }; |
| 3991 |
stk::mesh::EntityId hexElemOwningProc[] = { 0, 0 }; |
| 3992 |
|
| 3993 |
std::vector<stk::mesh::EntityIdVector> shellNodeIDs { |
| 3994 |
{ 5, 6, 7, 8 } |
| 3995 |
}; |
| 3996 |
stk::mesh::EntityId shellElemIDs[] = { 3 }; |
| 3997 |
stk::mesh::EntityId shellElemOwningProc[] = { 1 }; |
| 3998 |
|
| 3999 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 4000 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 4001 |
{ |
| 4002 |
{ 0, 5, 1 }, // proc 0 |
| 4003 |
{ 0, 6, 1 }, |
| 4004 |
{ 0, 7, 1 }, |
| 4005 |
{ 0, 8, 1 }, |
| 4006 |
{ 1, 5, 0 }, // proc 1 |
| 4007 |
{ 1, 6, 0 }, |
| 4008 |
{ 1, 7, 0 }, |
| 4009 |
{ 1, 8, 0 } |
| 4010 |
}; |
| 4011 |
|
| 4012 |
mesh.modification_begin(); |
| 4013 |
for (size_t i = 0; i < hexNodeIDs.size(); ++i) { |
| 4014 |
if (hexElemOwningProc[i] == p_rank) { |
| 4015 |
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]); |
| 4016 |
} |
| 4017 |
} |
| 4018 |
if (1 == p_rank) { |
| 4019 |
mesh.declare_node(5); |
| 4020 |
mesh.declare_node(6); |
| 4021 |
mesh.declare_node(7); |
| 4022 |
mesh.declare_node(8); |
| 4023 |
} |
| 4024 |
setup_node_sharing(mesh, shared_nodeIDs_and_procs ); |
| 4025 |
mesh.modification_end(); |
| 4026 |
|
| 4027 |
ElemElemGraphTester elemElemGraph(mesh); |
| 4028 |
|
| 4029 |
mesh.modification_begin(); |
| 4030 |
for (size_t i = 0; i < shellNodeIDs.size(); ++i) { |
| 4031 |
if (shellElemOwningProc[i] == p_rank) { |
| 4032 |
stk::mesh::declare_element(mesh, *shellPart, shellElemIDs[i], shellNodeIDs[i]); |
| 4033 |
} |
| 4034 |
} |
| 4035 |
mesh.modification_end(); |
| 4036 |
|
| 4037 |
const Entity hex1 = mesh.get_entity(stk::topology::ELEM_RANK, 1); |
| 4038 |
const Entity hex2 = mesh.get_entity(stk::topology::ELEM_RANK, 2); |
| 4039 |
const Entity shell3 = mesh.get_entity(stk::topology::ELEM_RANK, 3); |
| 4040 |
|
| 4041 |
stk::mesh::EntityVector addVector; |
| 4042 |
if (1 == p_rank) { |
| 4043 |
addVector.push_back(shell3); |
| 4044 |
} |
| 4045 |
elemElemGraph.add_elements(addVector); |
| 4046 |
|
| 4047 |
if (p_rank == 0) { |
| 4048 |
// Connectivity for Hex Element 1 |
| 4049 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 4050 |
EXPECT_EQ(5, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).side); |
| 4051 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex1, 0).id); |
| 4052 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 4053 |
|
| 4054 |
// Connectivity for Hex Element 2 |
| 4055 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex2)); |
| 4056 |
EXPECT_EQ(4, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).side); |
| 4057 |
EXPECT_EQ(3u, elemElemGraph.get_connected_remote_id_and_via_side(hex2, 0).id); |
| 4058 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 4059 |
} |
| 4060 |
else if (p_rank == 1) { |
| 4061 |
// Connectivity for Shell Element 3 |
| 4062 |
unsigned hex1Index = 0; |
| 4063 |
unsigned hex2Index = 1; |
| 4064 |
EXPECT_EQ(2u, elemElemGraph.get_num_connected_elems(shell3)); |
| 4065 |
EXPECT_EQ(1, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex1Index).side); |
| 4066 |
EXPECT_EQ(0, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex2Index).side); |
| 4067 |
EXPECT_EQ(1u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex1Index).id); |
| 4068 |
EXPECT_EQ(2u, elemElemGraph.get_connected_remote_id_and_via_side(shell3, hex2Index).id); |
| 4069 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, hex1Index)); |
| 4070 |
EXPECT_FALSE(elemElemGraph.is_connected_elem_locally_owned(shell3, hex2Index)); |
| 4071 |
} |
| 4072 |
|
| 4073 |
EXPECT_EQ(2u, elemElemGraph.num_edges()); |
| 4074 |
EXPECT_EQ(2u, elemElemGraph.num_parallel_edges()); |
| 4075 |
} |
| 4076 |
|
| 4077 |
TEST( ElementGraph, Hex0DelShell1Hex0Parallel ) |
| 4078 |
{ |
| 4079 |
stk::ParallelMachine pm = MPI_COMM_WORLD; |
| 4080 |
unsigned p_size = stk::parallel_machine_size(pm); |
| 4081 |
unsigned p_rank = stk::parallel_machine_rank(pm); |
| 4082 |
|
| 4083 |
if(p_size != 2u) |
| 4084 |
{ |
| 4085 |
return; |
| 4086 |
} |
| 4087 |
|
| 4088 |
std::vector<int> hexElemOwningProc = { 0, 0 }; |
| 4089 |
std::vector<int> shellElemOwningProc = { 1 }; |
| 4090 |
|
| 4091 |
// list of triplets: (owner-proc, shared-nodeID, sharing-proc) |
| 4092 |
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs |
| 4093 |
{ |
| 4094 |
{ 0, 5, 1 }, // proc 0 |
| 4095 |
{ 0, 6, 1 }, |
| 4096 |
{ 0, 7, 1 }, |
| 4097 |
{ 0, 8, 1 }, |
| 4098 |
{ 1, 5, 0 }, // proc 1 |
| 4099 |
{ 1, 6, 0 }, |
| 4100 |
{ 1, 7, 0 }, |
| 4101 |
{ 1, 8, 0 } |
| 4102 |
}; |
| 4103 |
|
| 4104 |
HexShellHexMesh mesh(pm, hexElemOwningProc, shellElemOwningProc, shared_nodeIDs_and_procs); |
| 4105 |
|
| 4106 |
ElemElemGraphTester elemElemGraph(mesh.get_bulk()); |
| 4107 |
|
| 4108 |
EXPECT_EQ(2u, elemElemGraph.num_edges()); |
| 4109 |
EXPECT_EQ(2u, elemElemGraph.num_parallel_edges()); |
| 4110 |
|
| 4111 |
const Entity hex1 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 1); |
| 4112 |
const Entity hex2 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 2); |
| 4113 |
const Entity shell3 = mesh.get_bulk().get_entity(stk::topology::ELEM_RANK, 3); |
| 4114 |
|
| 4115 |
stk::mesh::impl::DeletedElementInfoVector elements_to_delete; |
| 4116 |
if (p_rank == 1) { |
| 4117 |
elements_to_delete.push_back({shell3, 3, mesh.get_bulk().bucket(shell3).topology()}); |
| 4118 |
} |
| 4119 |
|
| 4120 |
elemElemGraph.delete_elements( elements_to_delete ); |
| 4121 |
|
| 4122 |
mesh.get_bulk().modification_begin(); |
| 4123 |
if (p_rank == 1) { |
| 4124 |
mesh.get_bulk().destroy_entity(shell3); |
| 4125 |
} |
| 4126 |
mesh.get_bulk().modification_end(); |
| 4127 |
|
| 4128 |
if (p_rank == 0) { |
| 4129 |
EXPECT_EQ(2u, elemElemGraph.num_edges()); |
| 4130 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 4131 |
|
| 4132 |
{ |
| 4133 |
// Connectivity for Hex Element 1 |
| 4134 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex1)); |
| 4135 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex1, 0); |
| 4136 |
EXPECT_EQ(5, elem_via_side.side); |
| 4137 |
EXPECT_EQ(hex2, elem_via_side.element); |
| 4138 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex1, 0)); |
| 4139 |
} |
| 4140 |
{ |
| 4141 |
// Connectivity for Hex Element 2 |
| 4142 |
EXPECT_EQ(1u, elemElemGraph.get_num_connected_elems(hex2)); |
| 4143 |
impl::ElementViaSidePair elem_via_side = elemElemGraph.get_connected_element_and_via_side(hex2, 0); |
| 4144 |
EXPECT_EQ(4, elem_via_side.side); |
| 4145 |
EXPECT_EQ(hex1, elem_via_side.element); |
| 4146 |
EXPECT_TRUE(elemElemGraph.is_connected_elem_locally_owned(hex2, 0)); |
| 4147 |
} |
| 4148 |
} |
| 4149 |
else if (p_rank == 1) { |
| 4150 |
EXPECT_EQ(0u, elemElemGraph.size()); |
| 4151 |
EXPECT_EQ(0u, elemElemGraph.num_edges()); |
| 4152 |
EXPECT_EQ(0u, elemElemGraph.num_parallel_edges()); |
| 4153 |
} |
| 4154 |
} |
| 4155 |
|
| 4156 |
void test_add_element_to_graph_with_element_death(stk::mesh::BulkData::AutomaticAuraOption /*autoAuraOption*/) |
| 4157 |
{ |
| 4158 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 4159 |
int pSize = stk::parallel_machine_size(comm); |
| 4160 |
int pRank = stk::parallel_machine_rank(comm); |
| 4161 |
|
| 4162 |
if(2 == pSize) |
| 4163 |
{ |
| 4164 |
const unsigned spatialDim = 3; |
| 4165 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, comm); |
| 4166 |
stk::mesh::BulkData& bulkData = *bulkPtr; |
| 4167 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 4168 |
|
| 4169 |
stk::mesh::Part& faces_part = meta.declare_part_with_topology("surface_5", stk::topology::QUAD_4); |
| 4170 |
stk::mesh::PartVector boundary_mesh_parts {&faces_part}; |
| 4171 |
stk::io::put_io_part_attribute(faces_part); |
| 4172 |
|
| 4173 |
stk::mesh::Part& active = meta.declare_part("active"); // can't specify rank, because it gets checked against size of rank_names |
| 4174 |
|
| 4175 |
test_add_elements_to_pre_existing_graph_and_mesh(bulkData); |
| 4176 |
stk::mesh::ElemElemGraph &graph = bulkData.get_face_adjacent_element_graph(); |
| 4177 |
|
| 4178 |
stk::unit_test_util::put_mesh_into_part(bulkData, active); |
| 4179 |
|
| 4180 |
stk::mesh::EntityVector deactivated_elems; |
| 4181 |
|
| 4182 |
if (0 == pRank) |
| 4183 |
deactivated_elems.push_back(bulkData.get_entity(stk::topology::ELEM_RANK, 1)); |
| 4184 |
else |
| 4185 |
deactivated_elems.push_back(bulkData.get_entity(stk::topology::ELEM_RANK, 4)); |
| 4186 |
|
| 4187 |
std::vector<size_t> entity_counts; |
| 4188 |
stk::mesh::comm_mesh_counts(bulkData, entity_counts); |
| 4189 |
ASSERT_TRUE(entity_counts[stk::topology::FACE_RANK] == 0); |
| 4190 |
|
| 4191 |
boundary_mesh_parts.push_back(&active); |
| 4192 |
|
| 4193 |
ElemGraphTestUtils::deactivate_elements(deactivated_elems, bulkData, active); |
| 4194 |
|
| 4195 |
stk::mesh::impl::ParallelSelectedInfo remoteActiveSelector; |
| 4196 |
stk::mesh::impl::populate_selected_value_for_remote_elements(bulkData, graph, active, remoteActiveSelector); |
| 4197 |
|
| 4198 |
stk::mesh::process_killed_elements(bulkData, deactivated_elems, active, remoteActiveSelector, boundary_mesh_parts, &boundary_mesh_parts); |
| 4199 |
|
| 4200 |
if (0 == pRank) |
| 4201 |
{ |
| 4202 |
stk::mesh::EntityId elem1Id = 1; |
| 4203 |
stk::mesh::EntityId elem2Id = 2; |
| 4204 |
stk::mesh::Entity face_between_elem1_and_elem2 = ElemGraphTestUtils::get_face_between_element_ids(graph, bulkData, elem1Id, elem2Id); |
| 4205 |
|
| 4206 |
ASSERT_TRUE(bulkData.is_valid(face_between_elem1_and_elem2)); |
| 4207 |
EXPECT_TRUE(bulkData.bucket(face_between_elem1_and_elem2).member(active)); |
| 4208 |
|
| 4209 |
stk::mesh::Entity elem1 = bulkData.get_entity(stk::topology::ELEM_RANK, 1); |
| 4210 |
stk::mesh::Entity elem3 = bulkData.get_entity(stk::topology::ELEM_RANK, 3); |
| 4211 |
EXPECT_FALSE(bulkData.bucket(elem1).member(active)); |
| 4212 |
EXPECT_TRUE(bulkData.bucket(elem3).member(active)); |
| 4213 |
} |
| 4214 |
else |
| 4215 |
{ |
| 4216 |
stk::mesh::EntityId elem3Id = 3; |
| 4217 |
stk::mesh::EntityId elem4Id = 4; |
| 4218 |
stk::mesh::Entity face_between_elem3_and_elem4 = ElemGraphTestUtils::get_face_between_element_ids(graph, bulkData, elem3Id, elem4Id); |
| 4219 |
|
| 4220 |
ASSERT_TRUE(bulkData.is_valid(face_between_elem3_and_elem4)); |
| 4221 |
EXPECT_TRUE(bulkData.bucket(face_between_elem3_and_elem4).member(active)); |
| 4222 |
|
| 4223 |
stk::mesh::Entity elem2 = bulkData.get_entity(stk::topology::ELEM_RANK, 2); |
| 4224 |
stk::mesh::Entity elem4 = bulkData.get_entity(stk::topology::ELEM_RANK, 4); |
| 4225 |
EXPECT_TRUE(bulkData.bucket(elem2).member(active)); |
| 4226 |
EXPECT_FALSE(bulkData.bucket(elem4).member(active)); |
| 4227 |
} |
| 4228 |
|
| 4229 |
// bulkData.dump_all_mesh_info(std::cout, true); |
| 4230 |
stk::mesh::comm_mesh_counts(bulkData, entity_counts); |
| 4231 |
ASSERT_TRUE(entity_counts[stk::topology::FACE_RANK] == 2); |
| 4232 |
|
| 4233 |
EXPECT_EQ(4u, graph.num_edges()); |
| 4234 |
EXPECT_EQ(4u, graph.num_parallel_edges()); |
| 4235 |
} |
| 4236 |
} |
| 4237 |
|
| 4238 |
TEST(ElementGraph, add_element_to_graph_with_element_death_aura_on) |
| 4239 |
{ |
| 4240 |
test_add_element_to_graph_with_element_death(stk::mesh::BulkData::AUTO_AURA); |
| 4241 |
} |
| 4242 |
|
| 4243 |
TEST(ElementGraph, add_element_to_graph_with_element_death_aura_off) |
| 4244 |
{ |
| 4245 |
test_add_element_to_graph_with_element_death(stk::mesh::BulkData::NO_AUTO_AURA); |
| 4246 |
} |
| 4247 |
|
| 4248 |
void test_delete_element_from_graph_with_element_death(stk::mesh::BulkData::AutomaticAuraOption /*autoAuraOption*/) |
| 4249 |
{ |
| 4250 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 4251 |
int pSize = stk::parallel_machine_size(comm); |
| 4252 |
int pRank = stk::parallel_machine_rank(comm); |
| 4253 |
|
| 4254 |
if(3 == pSize) |
| 4255 |
{ |
| 4256 |
const int procRank = stk::parallel_machine_rank(comm); |
| 4257 |
unsigned spatialDim = 3; |
| 4258 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, comm); |
| 4259 |
stk::mesh::BulkData& bulkData = *bulkPtr; |
| 4260 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 4261 |
|
| 4262 |
stk::mesh::Part& faces_part = meta.declare_part_with_topology("surface_5", stk::topology::QUAD_4); |
| 4263 |
stk::mesh::PartVector boundary_mesh_parts {&faces_part}; |
| 4264 |
stk::io::put_io_part_attribute(faces_part); |
| 4265 |
|
| 4266 |
stk::mesh::Part& active = meta.declare_part("active"); // can't specify rank, because it gets checked against size of rank_names |
| 4267 |
|
| 4268 |
stk::io::fill_mesh("generated:3x1x3", bulkData); |
| 4269 |
|
| 4270 |
bulkData.modification_begin(); |
| 4271 |
if (procRank == 0) { |
| 4272 |
stk::mesh::Entity element1 = bulkData.get_entity(stk::topology::ELEM_RANK,1); |
| 4273 |
stk::mesh::Entity element3 = bulkData.get_entity(stk::topology::ELEM_RANK,3); |
| 4274 |
bulkData.destroy_entity(element1); |
| 4275 |
bulkData.destroy_entity(element3); |
| 4276 |
} |
| 4277 |
if (procRank == 2) { |
| 4278 |
stk::mesh::Entity element7 = bulkData.get_entity(stk::topology::ELEM_RANK,7); |
| 4279 |
stk::mesh::Entity element9 = bulkData.get_entity(stk::topology::ELEM_RANK,9); |
| 4280 |
bulkData.destroy_entity(element7); |
| 4281 |
bulkData.destroy_entity(element9); |
| 4282 |
} |
| 4283 |
bulkData.modification_end(); |
| 4284 |
|
| 4285 |
stk::mesh::ElemElemGraph &graph = bulkData.get_face_adjacent_element_graph(); |
| 4286 |
|
| 4287 |
stk::unit_test_util::put_mesh_into_part(bulkData, active); |
| 4288 |
|
| 4289 |
stk::mesh::EntityVector deactivated_elems; |
| 4290 |
|
| 4291 |
if (1 == pRank) |
| 4292 |
{ |
| 4293 |
deactivated_elems.push_back(bulkData.get_entity(stk::topology::ELEM_RANK, 5)); |
| 4294 |
} |
| 4295 |
|
| 4296 |
std::vector<size_t> entity_counts; |
| 4297 |
stk::mesh::comm_mesh_counts(bulkData, entity_counts); |
| 4298 |
ASSERT_TRUE(entity_counts[stk::topology::FACE_RANK] == 0); |
| 4299 |
|
| 4300 |
boundary_mesh_parts.push_back(&active); |
| 4301 |
|
| 4302 |
ElemGraphTestUtils::deactivate_elements(deactivated_elems, bulkData, active); |
| 4303 |
|
| 4304 |
stk::mesh::impl::ParallelSelectedInfo remoteActiveSelector; |
| 4305 |
stk::mesh::impl::populate_selected_value_for_remote_elements(bulkData, graph, active, remoteActiveSelector); |
| 4306 |
|
| 4307 |
stk::mesh::process_killed_elements(bulkData, deactivated_elems, active, remoteActiveSelector, boundary_mesh_parts, &boundary_mesh_parts); |
| 4308 |
|
| 4309 |
stk::mesh::comm_mesh_counts(bulkData, entity_counts); |
| 4310 |
|
| 4311 |
ASSERT_EQ(4u, entity_counts[stk::topology::FACE_RANK]); |
| 4312 |
|
| 4313 |
if (0 == pRank) |
| 4314 |
{ |
| 4315 |
stk::mesh::EntityId elem2Id = 2; |
| 4316 |
stk::mesh::EntityId elem5Id = 5; |
| 4317 |
stk::mesh::Entity face_between_elem2_and_elem5 = ElemGraphTestUtils::get_face_between_element_ids(graph, bulkData, elem2Id, elem5Id); |
| 4318 |
|
| 4319 |
ASSERT_TRUE(bulkData.is_valid(face_between_elem2_and_elem5)); |
| 4320 |
EXPECT_TRUE(bulkData.bucket(face_between_elem2_and_elem5).member(active)); |
| 4321 |
|
| 4322 |
stk::mesh::Entity elem2 = bulkData.get_entity(stk::topology::ELEM_RANK, 2); |
| 4323 |
EXPECT_TRUE(bulkData.bucket(elem2).member(active)); |
| 4324 |
|
| 4325 |
EXPECT_EQ(1u, graph.num_edges()); |
| 4326 |
EXPECT_EQ(1u, graph.num_parallel_edges()); |
| 4327 |
} |
| 4328 |
else if(1 == pRank) |
| 4329 |
{ |
| 4330 |
stk::mesh::EntityId elem4Id = 4; |
| 4331 |
stk::mesh::EntityId elem5Id = 5; |
| 4332 |
stk::mesh::EntityId elem6Id = 6; |
| 4333 |
stk::mesh::Entity face_between_elem4_and_elem5 = ElemGraphTestUtils::get_face_between_element_ids(graph, bulkData, elem4Id, elem5Id); |
| 4334 |
stk::mesh::Entity face_between_elem6_and_elem5 = ElemGraphTestUtils::get_face_between_element_ids(graph, bulkData, elem6Id, elem5Id); |
| 4335 |
|
| 4336 |
ASSERT_TRUE(bulkData.is_valid(face_between_elem4_and_elem5)); |
| 4337 |
EXPECT_TRUE(bulkData.bucket(face_between_elem4_and_elem5).member(active)); |
| 4338 |
|
| 4339 |
ASSERT_TRUE(bulkData.is_valid(face_between_elem6_and_elem5)); |
| 4340 |
EXPECT_TRUE(bulkData.bucket(face_between_elem6_and_elem5).member(active)); |
| 4341 |
|
| 4342 |
stk::mesh::Entity elem4 = bulkData.get_entity(stk::topology::ELEM_RANK, 4); |
| 4343 |
stk::mesh::Entity elem5 = bulkData.get_entity(stk::topology::ELEM_RANK, 5); |
| 4344 |
stk::mesh::Entity elem6 = bulkData.get_entity(stk::topology::ELEM_RANK, 6); |
| 4345 |
|
| 4346 |
EXPECT_TRUE(bulkData.bucket(elem4).member(active)); |
| 4347 |
EXPECT_TRUE(bulkData.bucket(elem6).member(active)); |
| 4348 |
EXPECT_FALSE(bulkData.bucket(elem5).member(active)); |
| 4349 |
|
| 4350 |
EXPECT_EQ(6u, graph.num_edges()); |
| 4351 |
EXPECT_EQ(2u, graph.num_parallel_edges()); |
| 4352 |
} |
| 4353 |
else if (2 == pRank) |
| 4354 |
{ |
| 4355 |
stk::mesh::EntityId elem8Id = 8; |
| 4356 |
stk::mesh::EntityId elem5Id = 5; |
| 4357 |
stk::mesh::Entity face_between_elem8_and_elem5 = ElemGraphTestUtils::get_face_between_element_ids(graph, bulkData, elem8Id, elem5Id); |
| 4358 |
|
| 4359 |
ASSERT_TRUE(bulkData.is_valid(face_between_elem8_and_elem5)); |
| 4360 |
EXPECT_TRUE(bulkData.bucket(face_between_elem8_and_elem5).member(active)); |
| 4361 |
|
| 4362 |
stk::mesh::Entity elem8 = bulkData.get_entity(stk::topology::ELEM_RANK, 8); |
| 4363 |
EXPECT_TRUE(bulkData.bucket(elem8).member(active)); |
| 4364 |
|
| 4365 |
EXPECT_EQ(1u, graph.num_edges()); |
| 4366 |
EXPECT_EQ(1u, graph.num_parallel_edges()); |
| 4367 |
} |
| 4368 |
} |
| 4369 |
} |
| 4370 |
|
| 4371 |
|
| 4372 |
TEST(ElementGraph, delete_element_from_graph_with_element_death_aura_on) |
| 4373 |
{ |
| 4374 |
test_delete_element_from_graph_with_element_death(stk::mesh::BulkData::AUTO_AURA); |
| 4375 |
} |
| 4376 |
|
| 4377 |
TEST(ElementGraph, delete_element_from_graph_with_element_death_aura_off) |
| 4378 |
{ |
| 4379 |
test_delete_element_from_graph_with_element_death(stk::mesh::BulkData::NO_AUTO_AURA); |
| 4380 |
} |
| 4381 |
|
| 4382 |
ElemElemGraphTester create_base_1x1x4_elem_graph(stk::ParallelMachine &comm, stk::mesh::BulkData &bulkData) |
| 4383 |
{ |
| 4384 |
unsigned nProc = stk::parallel_machine_size(comm); |
| 4385 |
unsigned myProc = stk::parallel_machine_rank(comm); |
| 4386 |
|
| 4387 |
STK_ThrowRequire(nProc <= 4); |
| 4388 |
|
| 4389 |
stk::io::fill_mesh("generated:1x1x4", bulkData); |
| 4390 |
|
| 4391 |
std::vector<size_t> counts; |
| 4392 |
stk::mesh::count_entities(bulkData.mesh_meta_data().locally_owned_part(), bulkData, counts); |
| 4393 |
unsigned numLocallyOwnedElems = counts[stk::topology::ELEM_RANK]; |
| 4394 |
|
| 4395 |
if(myProc != 0) |
| 4396 |
{ |
| 4397 |
EXPECT_EQ(4u/nProc, numLocallyOwnedElems); |
| 4398 |
} |
| 4399 |
else |
| 4400 |
{ |
| 4401 |
EXPECT_EQ((4u/nProc + 4u%nProc), numLocallyOwnedElems); |
| 4402 |
} |
| 4403 |
|
| 4404 |
ElemElemGraphTester elem_graph(bulkData); |
| 4405 |
|
| 4406 |
stk::mesh::Entity elem1 = bulkData.get_entity(stk::topology::ELEM_RANK, 1); |
| 4407 |
stk::mesh::Entity elem2 = bulkData.get_entity(stk::topology::ELEM_RANK, 2); |
| 4408 |
stk::mesh::Entity elem3 = bulkData.get_entity(stk::topology::ELEM_RANK, 3); |
| 4409 |
stk::mesh::Entity elem4 = bulkData.get_entity(stk::topology::ELEM_RANK, 4); |
| 4410 |
|
| 4411 |
// We know that element 1 has 1 connection |
| 4412 |
// 2 has 2 connections |
| 4413 |
// 3 has 2 connections |
| 4414 |
// 4 has 1 connection |
| 4415 |
|
| 4416 |
bool ownedElem1 = false; |
| 4417 |
bool ownedElem2 = false; |
| 4418 |
bool ownedElem3 = false; |
| 4419 |
bool ownedElem4 = false; |
| 4420 |
|
| 4421 |
unsigned numEdges = 0; |
| 4422 |
|
| 4423 |
if(bulkData.is_valid(elem1) && bulkData.bucket(elem1).owned()) |
| 4424 |
{ |
| 4425 |
numEdges += 1; |
| 4426 |
ownedElem1 = true; |
| 4427 |
} |
| 4428 |
if(bulkData.is_valid(elem2) && bulkData.bucket(elem2).owned()) |
| 4429 |
{ |
| 4430 |
numEdges += 2; |
| 4431 |
ownedElem2 = true; |
| 4432 |
} |
| 4433 |
|
| 4434 |
if(bulkData.is_valid(elem3) && bulkData.bucket(elem3).owned()) |
| 4435 |
{ |
| 4436 |
numEdges += 2; |
| 4437 |
ownedElem3 = true; |
| 4438 |
} |
| 4439 |
if(bulkData.is_valid(elem4) && bulkData.bucket(elem4).owned()) |
| 4440 |
{ |
| 4441 |
numEdges += 1; |
| 4442 |
ownedElem4 = true; |
| 4443 |
} |
| 4444 |
|
| 4445 |
unsigned numParallelEdges = 0; |
| 4446 |
for(unsigned elem_id=1; elem_id<=4; ++elem_id) |
| 4447 |
{ |
| 4448 |
stk::mesh::Entity elem = bulkData.get_entity(stk::topology::ELEM_RANK, elem_id); |
| 4449 |
|
| 4450 |
if (!bulkData.is_valid(elem) || !bulkData.bucket(elem).owned()) |
| 4451 |
{ |
| 4452 |
continue; |
| 4453 |
} |
| 4454 |
|
| 4455 |
stk::mesh::EntityId leftNeighbor = elem_id - 1; |
| 4456 |
stk::mesh::Entity leftElem = bulkData.get_entity(stk::topology::ELEM_RANK, leftNeighbor); |
| 4457 |
bool ownedLeftNeighbor = bulkData.is_valid(leftElem) && bulkData.bucket(leftElem).owned(); |
| 4458 |
if(!ownedLeftNeighbor && (elem_id > 1)) |
| 4459 |
{ |
| 4460 |
numParallelEdges++; |
| 4461 |
} |
| 4462 |
|
| 4463 |
stk::mesh::EntityId rightNeighbor = elem_id + 1; |
| 4464 |
stk::mesh::Entity rightElem = bulkData.get_entity(stk::topology::ELEM_RANK, rightNeighbor); |
| 4465 |
bool ownedRightNeighbor = bulkData.is_valid(rightElem) && bulkData.bucket(rightElem).owned(); |
| 4466 |
if(!ownedRightNeighbor && (elem_id < 4)) |
| 4467 |
{ |
| 4468 |
numParallelEdges++; |
| 4469 |
} |
| 4470 |
} |
| 4471 |
|
| 4472 |
EXPECT_EQ(numLocallyOwnedElems, elem_graph.size()); |
| 4473 |
EXPECT_EQ(numEdges, elem_graph.num_edges()); |
| 4474 |
EXPECT_EQ(numParallelEdges, elem_graph.num_parallel_edges()); |
| 4475 |
|
| 4476 |
if (ownedElem1) |
| 4477 |
{ |
| 4478 |
EXPECT_EQ(5, elem_graph.get_side_from_element1_to_element2(1, 2)); |
| 4479 |
EXPECT_EQ(-1, elem_graph.get_side_from_element1_to_element2(1, 3)); |
| 4480 |
EXPECT_EQ(-1, elem_graph.get_side_from_element1_to_element2(1, 4)); |
| 4481 |
|
| 4482 |
} |
| 4483 |
if (ownedElem2) |
| 4484 |
{ |
| 4485 |
EXPECT_EQ(4, elem_graph.get_side_from_element1_to_element2(2, 1)); |
| 4486 |
EXPECT_EQ(5, elem_graph.get_side_from_element1_to_element2(2, 3)); |
| 4487 |
EXPECT_EQ(-1, elem_graph.get_side_from_element1_to_element2(2, 4)); |
| 4488 |
} |
| 4489 |
if (ownedElem3) |
| 4490 |
{ |
| 4491 |
EXPECT_EQ(4, elem_graph.get_side_from_element1_to_element2(3, 2)); |
| 4492 |
EXPECT_EQ(5, elem_graph.get_side_from_element1_to_element2(3, 4)); |
| 4493 |
EXPECT_EQ(-1, elem_graph.get_side_from_element1_to_element2(3, 1)); |
| 4494 |
} |
| 4495 |
if (ownedElem4) |
| 4496 |
{ |
| 4497 |
EXPECT_EQ(4, elem_graph.get_side_from_element1_to_element2(4, 3)); |
| 4498 |
EXPECT_EQ(-1, elem_graph.get_side_from_element1_to_element2(4, 1)); |
| 4499 |
EXPECT_EQ(-1, elem_graph.get_side_from_element1_to_element2(4, 2)); |
| 4500 |
} |
| 4501 |
|
| 4502 |
return elem_graph; |
| 4503 |
} |
| 4504 |
|
| 4505 |
// element ids / proc_id: |
| 4506 |
// |-------|-------|-------| |
| 4507 |
// | | | | |
| 4508 |
// | 1/0 | 4/2 | 7/2 | |
| 4509 |
// | | | | |
| 4510 |
// |-------|-------|-------| |
| 4511 |
// | | | | |
| 4512 |
// | 2/0 | 5/1 | 8/2 | |
| 4513 |
// | | | | |
| 4514 |
// |-------|-------|-------| |
| 4515 |
// | | | | |
| 4516 |
// | 3/0 | 6/2 | 9/2 | |
| 4517 |
// | | | | |
| 4518 |
// |-------|-------|-------| |
| 4519 |
|
| 4520 |
|
| 4521 |
TEST(ElementGraph, TestKeyHoleSimilarProblemAInParallel) |
| 4522 |
{ |
| 4523 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 4524 |
|
| 4525 |
if(stk::parallel_machine_size(comm) == 3) |
| 4526 |
{ |
| 4527 |
const int procRank = stk::parallel_machine_rank(comm); |
| 4528 |
unsigned spatialDim = 3; |
| 4529 |
|
| 4530 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, comm, stk::mesh::BulkData::NO_AUTO_AURA); |
| 4531 |
stk::mesh::BulkData& bulkData = *bulkPtr; |
| 4532 |
stk::io::fill_mesh("generated:3x1x3", bulkData); |
| 4533 |
|
| 4534 |
stk::mesh::EntityProcVec elementProcChanges; |
| 4535 |
if (procRank == 1) { |
| 4536 |
elementProcChanges.push_back(stk::mesh::EntityProc(bulkData.get_entity(stk::topology::ELEM_RANK,4),2)); |
| 4537 |
elementProcChanges.push_back(stk::mesh::EntityProc(bulkData.get_entity(stk::topology::ELEM_RANK,6),2)); |
| 4538 |
} |
| 4539 |
bulkData.change_entity_owner(elementProcChanges); |
| 4540 |
|
| 4541 |
ElemElemGraphTester graph(bulkData); |
| 4542 |
if (procRank == 0) { |
| 4543 |
stk::mesh::Entity local_element = bulkData.get_entity(stk::topology::ELEM_RANK,2); |
| 4544 |
ASSERT_TRUE(bulkData.bucket(local_element).owned()); |
| 4545 |
ASSERT_EQ(3u, graph.get_num_connected_elems(local_element)); |
| 4546 |
|
| 4547 |
EXPECT_EQ( 3, graph.get_connected_element_and_via_side(local_element,0).side); |
| 4548 |
EXPECT_EQ( 1, graph.get_connected_element_and_via_side(local_element,1).side); |
| 4549 |
EXPECT_EQ( 5, graph.get_connected_remote_id_and_via_side(local_element,2).side); |
| 4550 |
|
| 4551 |
EXPECT_TRUE(graph.is_connected_elem_locally_owned(local_element, 0)); |
| 4552 |
EXPECT_TRUE(graph.is_connected_elem_locally_owned(local_element, 1)); |
| 4553 |
EXPECT_FALSE(graph.is_connected_elem_locally_owned(local_element, 2)); |
| 4554 |
|
| 4555 |
EXPECT_EQ( 1u, bulkData.identifier(graph.get_connected_element_and_via_side(local_element, 0).element)); |
| 4556 |
EXPECT_EQ( 3u, bulkData.identifier(graph.get_connected_element_and_via_side(local_element, 1).element)); |
| 4557 |
EXPECT_EQ( 5u, graph.get_connected_remote_id_and_via_side(local_element, 2).id); |
| 4558 |
|
| 4559 |
EXPECT_EQ( 1, graph.get_owning_proc_id_of_remote_element(local_element, 2)); |
| 4560 |
|
| 4561 |
EXPECT_EQ(7u, graph.num_edges()); |
| 4562 |
EXPECT_EQ(3u, graph.num_parallel_edges()); |
| 4563 |
} |
| 4564 |
if (procRank == 1) { |
| 4565 |
stk::mesh::Entity local_element = bulkData.get_entity(stk::topology::ELEM_RANK,5); |
| 4566 |
ASSERT_TRUE(bulkData.bucket(local_element).owned()); |
| 4567 |
size_t numConnectedElems = graph.get_num_connected_elems(local_element); |
| 4568 |
ASSERT_EQ(4u, numConnectedElems); |
| 4569 |
|
| 4570 |
EXPECT_EQ( 4, graph.get_connected_remote_id_and_via_side(local_element,0).side); |
| 4571 |
EXPECT_EQ( 3, graph.get_connected_remote_id_and_via_side(local_element,1).side); |
| 4572 |
EXPECT_EQ( 1, graph.get_connected_remote_id_and_via_side(local_element,2).side); |
| 4573 |
EXPECT_EQ( 5, graph.get_connected_remote_id_and_via_side(local_element,3).side); |
| 4574 |
|
| 4575 |
EXPECT_FALSE(graph.is_connected_elem_locally_owned(local_element, 0)); |
| 4576 |
EXPECT_FALSE(graph.is_connected_elem_locally_owned(local_element, 1)); |
| 4577 |
EXPECT_FALSE(graph.is_connected_elem_locally_owned(local_element, 2)); |
| 4578 |
EXPECT_FALSE(graph.is_connected_elem_locally_owned(local_element, 3)); |
| 4579 |
|
| 4580 |
EXPECT_EQ( 2u, graph.get_connected_remote_id_and_via_side(local_element, 0).id); |
| 4581 |
EXPECT_EQ( 4u, graph.get_connected_remote_id_and_via_side(local_element, 1).id); |
| 4582 |
EXPECT_EQ( 6u, graph.get_connected_remote_id_and_via_side(local_element, 2).id); |
| 4583 |
EXPECT_EQ( 8u, graph.get_connected_remote_id_and_via_side(local_element, 3).id); |
| 4584 |
|
| 4585 |
EXPECT_EQ( 0, graph.get_owning_proc_id_of_remote_element(local_element, 0)); |
| 4586 |
EXPECT_EQ( 2, graph.get_owning_proc_id_of_remote_element(local_element, 1)); |
| 4587 |
EXPECT_EQ( 2, graph.get_owning_proc_id_of_remote_element(local_element, 2)); |
| 4588 |
EXPECT_EQ( 2, graph.get_owning_proc_id_of_remote_element(local_element, 3)); |
| 4589 |
|
| 4590 |
EXPECT_EQ(4u, graph.num_edges()); |
| 4591 |
EXPECT_EQ(4u, graph.num_parallel_edges()); |
| 4592 |
} |
| 4593 |
if (procRank == 2) { |
| 4594 |
EXPECT_EQ(13u, graph.num_edges()); |
| 4595 |
EXPECT_EQ( 5u, graph.num_parallel_edges()); |
| 4596 |
} |
| 4597 |
} |
| 4598 |
} |
| 4599 |
|
| 4600 |
TEST(TestAuraHex, TestKeyHoleSimilarProblemBInParallel) |
| 4601 |
{ |
| 4602 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 4603 |
|
| 4604 |
if(stk::parallel_machine_size(comm) != 3) { GTEST_SKIP(); } |
| 4605 |
|
| 4606 |
const int procRank = stk::parallel_machine_rank(comm); |
| 4607 |
unsigned spatialDim = 3; |
| 4608 |
|
| 4609 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, comm); |
| 4610 |
stk::mesh::BulkData& bulkData = *bulkPtr; |
| 4611 |
stk::io::fill_mesh("generated:3x1x3", bulkData); |
| 4612 |
|
| 4613 |
{ |
| 4614 |
stk::mesh::EntityProcVec elementProcChanges; |
| 4615 |
if (procRank == 1) { |
| 4616 |
elementProcChanges.push_back(stk::mesh::EntityProc(bulkData.get_entity(stk::topology::ELEM_RANK,4),2)); |
| 4617 |
elementProcChanges.push_back(stk::mesh::EntityProc(bulkData.get_entity(stk::topology::ELEM_RANK,6),2)); |
| 4618 |
} |
| 4619 |
bulkData.change_entity_owner(elementProcChanges); |
| 4620 |
} |
| 4621 |
|
| 4622 |
{ |
| 4623 |
stk::parallel_machine_barrier(bulkData.parallel()); |
| 4624 |
std::ostringstream os; |
| 4625 |
os<<"P"<<bulkData.parallel_rank()<<" ****************** about to do test mod"<<std::endl; |
| 4626 |
stk::mesh::EntityVector elems; |
| 4627 |
stk::mesh::get_entities(bulkData, stk::topology::ELEM_RANK, bulkData.mesh_meta_data().locally_owned_part(), elems); |
| 4628 |
for(stk::mesh::Entity elem : elems) { |
| 4629 |
os<<bulkData.entity_key(elem)<<" nodes: "; |
| 4630 |
const stk::mesh::Entity* nodes = bulkData.begin_nodes(elem); |
| 4631 |
for(int i=0; i<8; ++i) os<<bulkData.identifier(nodes[i])<<" o="<<bulkData.parallel_owner_rank(nodes[i])<<",s="<<bulkData.bucket(nodes[i]).shared()<<",a="<<bulkData.bucket(nodes[i]).in_aura()<<"; "; |
| 4632 |
os<<std::endl; |
| 4633 |
} |
| 4634 |
std::cerr<<os.str(); |
| 4635 |
stk::parallel_machine_barrier(bulkData.parallel()); |
| 4636 |
} |
| 4637 |
bulkData.modification_begin(); |
| 4638 |
if (procRank == 1) { |
| 4639 |
stk::mesh::Entity elem5 = bulkData.get_entity(stk::topology::ELEM_RANK,5); |
| 4640 |
ASSERT_TRUE(bulkData.parallel_owner_rank(elem5)==1); |
| 4641 |
{ |
| 4642 |
std::ostringstream os; |
| 4643 |
os<<"P"<<bulkData.parallel_rank()<<" elem5 nodes: "; |
| 4644 |
const stk::mesh::Entity* nodes = bulkData.begin_nodes(elem5); |
| 4645 |
for(int i=0; i<8; ++i) { |
| 4646 |
os<<bulkData.identifier(nodes[i])<<" o="<<bulkData.parallel_owner_rank(nodes[i])<<",s="<<bulkData.bucket(nodes[i]).shared()<<",a="<<bulkData.bucket(nodes[i]).in_aura()<<"; "; |
| 4647 |
} |
| 4648 |
os<<std::endl; |
| 4649 |
std::cerr<<os.str(); |
| 4650 |
} |
| 4651 |
EXPECT_TRUE(bulkData.destroy_entity(elem5)); |
| 4652 |
} |
| 4653 |
bulkData.modification_end(); |
| 4654 |
} |
| 4655 |
|
| 4656 |
// element ids / proc_id: |
| 4657 |
// |-------|-------|-------| |
| 4658 |
// | | | | |
| 4659 |
// | 1/0 | 4/2 | 7/2 | |
| 4660 |
// | | | | |
| 4661 |
// |-------|-------|-------| |
| 4662 |
// | | | | |
| 4663 |
// | 2/0 | n/a | 8/2 | |
| 4664 |
// | | | | |
| 4665 |
// |-------|-------|-------| |
| 4666 |
// | | | | |
| 4667 |
// | 3/0 | 6/2 | 9/2 | |
| 4668 |
// | | | | |
| 4669 |
// |-------|-------|-------| |
| 4670 |
// The element in the middle has been deleted |
| 4671 |
|
| 4672 |
TEST(ElementGraph, TestKeyHoleSimilarProblemBInParallel) |
| 4673 |
{ |
| 4674 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 4675 |
|
| 4676 |
if(stk::parallel_machine_size(comm) != 3) { GTEST_SKIP(); } |
| 4677 |
|
| 4678 |
const int procRank = stk::parallel_machine_rank(comm); |
| 4679 |
unsigned spatialDim = 3; |
| 4680 |
|
| 4681 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, comm); |
| 4682 |
stk::mesh::BulkData& bulkData = *bulkPtr; |
| 4683 |
stk::io::fill_mesh("generated:3x1x3", bulkData); |
| 4684 |
|
| 4685 |
stk::mesh::EntityProcVec elementProcChanges; |
| 4686 |
if (procRank == 1) { |
| 4687 |
elementProcChanges.push_back(stk::mesh::EntityProc(bulkData.get_entity(stk::topology::ELEM_RANK,4),2)); |
| 4688 |
elementProcChanges.push_back(stk::mesh::EntityProc(bulkData.get_entity(stk::topology::ELEM_RANK,6),2)); |
| 4689 |
} |
| 4690 |
|
| 4691 |
bulkData.change_entity_owner(elementProcChanges); |
| 4692 |
{ |
| 4693 |
stk::parallel_machine_barrier(bulkData.parallel()); |
| 4694 |
std::ostringstream os; |
| 4695 |
os<<"P"<<bulkData.parallel_rank()<<" about to do test mod"<<std::endl; |
| 4696 |
std::cerr<<os.str(); |
| 4697 |
stk::parallel_machine_barrier(bulkData.parallel()); |
| 4698 |
} |
| 4699 |
bulkData.modification_begin(); |
| 4700 |
if (procRank == 1) { |
| 4701 |
stk::mesh::Entity local_element5 = bulkData.get_entity(stk::topology::ELEM_RANK,5); |
| 4702 |
bulkData.destroy_entity(local_element5); |
| 4703 |
} |
| 4704 |
bulkData.modification_end(); |
| 4705 |
|
| 4706 |
ElemElemGraphTester graph(bulkData); |
| 4707 |
if (procRank == 0) { |
| 4708 |
EXPECT_EQ(2u, graph.get_num_connected_elems(bulkData.get_entity(stk::topology::ELEM_RANK,1))); |
| 4709 |
EXPECT_EQ(2u, graph.get_num_connected_elems(bulkData.get_entity(stk::topology::ELEM_RANK,2))); |
| 4710 |
EXPECT_EQ(2u, graph.get_num_connected_elems(bulkData.get_entity(stk::topology::ELEM_RANK,3))); |
| 4711 |
EXPECT_EQ(6u, graph.num_edges()); |
| 4712 |
EXPECT_EQ(2u, graph.num_parallel_edges()); |
| 4713 |
} |
| 4714 |
if (procRank == 1) { |
| 4715 |
EXPECT_EQ(0u, graph.size()); |
| 4716 |
EXPECT_EQ(0u, graph.num_edges()); |
| 4717 |
EXPECT_EQ(0u, graph.num_parallel_edges()); |
| 4718 |
} |
| 4719 |
if (procRank == 2) { |
| 4720 |
EXPECT_EQ(2u, graph.get_num_connected_elems(bulkData.get_entity(stk::topology::ELEM_RANK,4))); |
| 4721 |
EXPECT_EQ(2u, graph.get_num_connected_elems(bulkData.get_entity(stk::topology::ELEM_RANK,6))); |
| 4722 |
EXPECT_EQ(2u, graph.get_num_connected_elems(bulkData.get_entity(stk::topology::ELEM_RANK,7))); |
| 4723 |
EXPECT_EQ(2u, graph.get_num_connected_elems(bulkData.get_entity(stk::topology::ELEM_RANK,8))); |
| 4724 |
EXPECT_EQ(2u, graph.get_num_connected_elems(bulkData.get_entity(stk::topology::ELEM_RANK,9))); |
| 4725 |
EXPECT_EQ(10u, graph.num_edges()); |
| 4726 |
EXPECT_EQ( 2u, graph.num_parallel_edges()); |
| 4727 |
} |
| 4728 |
} |
| 4729 |
|
| 4730 |
void test_parallel_uniqueness(const std::vector<stk::mesh::EntityId> &ids_in_use, const std::vector<stk::mesh::EntityId>& requested_ids, stk::ParallelMachine comm) |
| 4731 |
{ |
| 4732 |
std::vector<stk::mesh::EntityId> global_ids_in_use; |
| 4733 |
stk::parallel_vector_concat(comm, ids_in_use, global_ids_in_use); |
| 4734 |
std::sort(global_ids_in_use.begin(), global_ids_in_use.end()); |
| 4735 |
|
| 4736 |
std::vector<stk::mesh::EntityId> global_requested_ids; |
| 4737 |
stk::parallel_vector_concat(comm, requested_ids, global_requested_ids); |
| 4738 |
std::sort(global_requested_ids.begin(), global_requested_ids.end()); |
| 4739 |
|
| 4740 |
std::vector<stk::mesh::EntityId> intersection; |
| 4741 |
|
| 4742 |
std::set_intersection(global_ids_in_use.begin(), global_ids_in_use.end(), |
| 4743 |
global_requested_ids.begin(), global_requested_ids.end(), |
| 4744 |
std::back_inserter(intersection)); |
| 4745 |
|
| 4746 |
EXPECT_TRUE(intersection.empty()); |
| 4747 |
} |
| 4748 |
|
| 4749 |
TEST(ElemGraph, test_id_reservation) |
| 4750 |
{ |
| 4751 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 4752 |
if(stk::parallel_machine_size(comm)==2) |
| 4753 |
{ |
| 4754 |
unsigned spatialDim = 3; |
| 4755 |
|
| 4756 |
stk::mesh::MetaData meta(spatialDim); |
| 4757 |
BulkDataElementGraphTester bulkData(meta, comm); |
| 4758 |
stk::io::fill_mesh("generated:1x1x4", bulkData); |
| 4759 |
|
| 4760 |
std::vector<stk::mesh::EntityId> ids_in_use = bulkData.my_internal_get_ids_in_use_this_proc_for_locally_owned(stk::topology::ELEM_RANK); |
| 4761 |
|
| 4762 |
size_t num_ids_requested_per_proc = 10; |
| 4763 |
std::vector<stk::mesh::EntityId> requested_ids; |
| 4764 |
bulkData.generate_new_ids(stk::topology::ELEM_RANK, num_ids_requested_per_proc, requested_ids); |
| 4765 |
|
| 4766 |
test_parallel_uniqueness(ids_in_use, requested_ids, comm); |
| 4767 |
|
| 4768 |
std::vector<stk::mesh::EntityId> requested_ids_again; |
| 4769 |
bulkData.generate_new_ids_given_reserved_ids(stk::topology::ELEM_RANK, num_ids_requested_per_proc, requested_ids, requested_ids_again); |
| 4770 |
|
| 4771 |
test_parallel_uniqueness(ids_in_use, requested_ids_again, comm); |
| 4772 |
test_parallel_uniqueness(requested_ids, requested_ids_again, comm); |
| 4773 |
} |
| 4774 |
} |
| 4775 |
|
| 4776 |
bool is_valid_graph_element(const impl::ElementGraph &elem_graph, stk::mesh::impl::LocalId elem_id) |
| 4777 |
{ |
| 4778 |
stk::mesh::impl::LocalId max_elem_id = static_cast<stk::mesh::impl::LocalId>(elem_graph.size()); |
| 4779 |
return (elem_id >= 0 && elem_id < max_elem_id); |
| 4780 |
} |
| 4781 |
|
| 4782 |
int check_connectivity(const impl::ElementGraph &elem_graph, const impl::SidesForElementGraph &via_sides, |
| 4783 |
stk::mesh::impl::LocalId element_id1, stk::mesh::impl::LocalId element_id2) |
| 4784 |
{ |
| 4785 |
int side=-1; |
| 4786 |
if (is_valid_graph_element(elem_graph, element_id1) && is_valid_graph_element(elem_graph, element_id2)) { |
| 4787 |
side = get_side_from_element1_to_element2(elem_graph, via_sides, element_id1, element_id2); |
| 4788 |
} |
| 4789 |
return side; |
| 4790 |
} |
| 4791 |
|
| 4792 |
int get_side_from_element1_to_element2(const impl::ElementGraph &elem_graph, |
| 4793 |
const impl::SidesForElementGraph &via_sides, |
| 4794 |
stk::mesh::impl::LocalId element1_local_id, |
| 4795 |
stk::mesh::impl::LocalId other_element_id) |
| 4796 |
{ |
| 4797 |
int side = -1; |
| 4798 |
const std::vector<stk::mesh::impl::LocalId>& conn_elements = elem_graph[element1_local_id]; |
| 4799 |
|
| 4800 |
std::vector<stk::mesh::impl::LocalId>::const_iterator iter = std::find(conn_elements.begin(), conn_elements.end(), other_element_id); |
| 4801 |
if ( iter != conn_elements.end() ) |
| 4802 |
{ |
| 4803 |
int64_t index = iter - conn_elements.begin(); |
| 4804 |
side = via_sides[element1_local_id][index]; |
| 4805 |
} |
| 4806 |
return side; |
| 4807 |
} |
| 4808 |
//EndDocExample1 |
| 4809 |
|
| 4810 |
void add_elem3_on_proc_1(stk::mesh::BulkData& bulk) |
| 4811 |
{ |
| 4812 |
stk::mesh::Part& block1 = *bulk.mesh_meta_data().get_part("block_1"); |
| 4813 |
stk::mesh::PartVector parts = {&block1}; |
| 4814 |
|
| 4815 |
bulk.modification_begin(); |
| 4816 |
|
| 4817 |
if (bulk.parallel_rank() == 1) |
| 4818 |
{ |
| 4819 |
stk::mesh::EntityId elemId = 3; |
| 4820 |
|
| 4821 |
stk::mesh::EntityIdVector nodeIds = {6, 13, 14, 8, 10, 15, 16, 12}; |
| 4822 |
stk::mesh::declare_element(bulk, parts, elemId, nodeIds); |
| 4823 |
} |
| 4824 |
|
| 4825 |
bulk.modification_end(); |
| 4826 |
} |
| 4827 |
|
| 4828 |
TEST(ElemGraph, get_all_sides_sideset_including_ghosts) |
| 4829 |
{ |
| 4830 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 4831 |
if(stk::parallel_machine_size(comm)==2) |
| 4832 |
{ |
| 4833 |
{ |
| 4834 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3, comm, stk::mesh::BulkData::AUTO_AURA); |
| 4835 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 4836 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 4837 |
stk::io::fill_mesh("generated:1x1x2", bulk); |
| 4838 |
add_elem3_on_proc_1(bulk); |
| 4839 |
|
| 4840 |
bool includeAuraElementSides = true; |
| 4841 |
std::vector<stk::mesh::SideSetEntry> sides = stk::mesh::SkinMeshUtil::get_all_sides_sideset(bulk, meta.universal_part(), includeAuraElementSides); |
| 4842 |
EXPECT_EQ(16u, sides.size()); |
| 4843 |
} |
| 4844 |
{ |
| 4845 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3, comm, stk::mesh::BulkData::AUTO_AURA); |
| 4846 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 4847 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 4848 |
stk::io::fill_mesh("generated:1x2x2", bulk); |
| 4849 |
bool includeAuraElementSides = true; |
| 4850 |
std::vector<stk::mesh::SideSetEntry> sides = stk::mesh::SkinMeshUtil::get_all_sides_sideset(bulk, meta.universal_part(), includeAuraElementSides); |
| 4851 |
EXPECT_EQ(20u, sides.size()); |
| 4852 |
} |
| 4853 |
{ |
| 4854 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3, comm, stk::mesh::BulkData::AUTO_AURA); |
| 4855 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 4856 |
stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); |
| 4857 |
stk::io::fill_mesh("generated:2x2x2", bulk); |
| 4858 |
bool includeAuraElementSides = true; |
| 4859 |
std::vector<stk::mesh::SideSetEntry> sides = stk::mesh::SkinMeshUtil::get_all_sides_sideset(bulk, meta.universal_part(), includeAuraElementSides); |
| 4860 |
EXPECT_EQ(36u, sides.size()); |
| 4861 |
} |
| 4862 |
} |
| 4863 |
} |
| 4864 |
|
| 4865 |
TEST(ElemGraph, test_initial_graph_creation_with_deactivated_elements) |
| 4866 |
{ |
| 4867 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 4868 |
if(stk::parallel_machine_size(comm)==2) |
| 4869 |
{ |
| 4870 |
stk::mesh::MetaData meta(3); |
| 4871 |
stk::mesh::Part &activePart = meta.declare_part("active"); |
| 4872 |
BulkDataElementGraphTester bulkData(meta, comm); |
| 4873 |
stk::io::fill_mesh("generated:1x1x4", bulkData); |
| 4874 |
stk::unit_test_util::put_mesh_into_part(bulkData, activePart); |
| 4875 |
|
| 4876 |
bulkData.modification_begin(); |
| 4877 |
if(bulkData.parallel_rank() == 0) |
| 4878 |
{ |
| 4879 |
stk::mesh::Entity elem2 = bulkData.get_entity(stk::topology::ELEMENT_RANK, 2); |
| 4880 |
bulkData.change_entity_parts(elem2, ConstPartVector{}, ConstPartVector{&activePart}); |
| 4881 |
} |
| 4882 |
bulkData.modification_end(); |
| 4883 |
|
| 4884 |
stk::mesh::ElemElemGraph graph(bulkData); |
| 4885 |
stk::mesh::impl::ParallelSelectedInfo remoteSkinSelector; |
| 4886 |
stk::mesh::impl::populate_selected_value_for_remote_elements(bulkData, graph, activePart, remoteSkinSelector); |
| 4887 |
if (bulkData.parallel_rank() == 0) { |
| 4888 |
stk::mesh::Entity elem1 = bulkData.get_entity(stk::topology::ELEM_RANK,1); |
| 4889 |
stk::mesh::Entity elem2 = bulkData.get_entity(stk::topology::ELEM_RANK,2); |
| 4890 |
|
| 4891 |
|
| 4892 |
ASSERT_EQ(1u, graph.get_num_connected_elems(elem1)); |
| 4893 |
|
| 4894 |
EXPECT_TRUE(graph.is_connected_elem_locally_owned(elem1, 0)); |
| 4895 |
EXPECT_EQ(elem2, graph.get_connected_element_and_via_side(elem1, 0).element); |
| 4896 |
|
| 4897 |
|
| 4898 |
ASSERT_EQ(2u, graph.get_num_connected_elems(elem2)); |
| 4899 |
|
| 4900 |
EXPECT_TRUE(graph.is_connected_elem_locally_owned(elem2, 0)); |
| 4901 |
EXPECT_EQ(elem1, graph.get_connected_element_and_via_side(elem2, 0).element); |
| 4902 |
|
| 4903 |
EXPECT_TRUE(!graph.is_connected_elem_locally_owned(elem2, 1)); |
| 4904 |
stk::mesh::EntityId remoteElemId = 3; |
| 4905 |
EXPECT_EQ(remoteElemId, graph.get_connected_remote_id_and_via_side(elem2, 1).id); |
| 4906 |
stk::mesh::impl::ParallelInfo ¶llelInfo = graph.get_parallel_edge_info(elem2, 5, remoteElemId, 4); |
| 4907 |
EXPECT_EQ(1, parallelInfo.get_proc_rank_of_neighbor()); |
| 4908 |
EXPECT_TRUE(remoteSkinSelector[-remoteElemId]); |
| 4909 |
} |
| 4910 |
else if (bulkData.parallel_rank() == 1) { |
| 4911 |
stk::mesh::Entity elem3 = bulkData.get_entity(stk::topology::ELEM_RANK,3); |
| 4912 |
stk::mesh::Entity elem4 = bulkData.get_entity(stk::topology::ELEM_RANK,4); |
| 4913 |
|
| 4914 |
|
| 4915 |
ASSERT_EQ(2u, graph.get_num_connected_elems(elem3)); |
| 4916 |
|
| 4917 |
EXPECT_TRUE(graph.is_connected_elem_locally_owned(elem3, 0)); |
| 4918 |
EXPECT_EQ(elem4, graph.get_connected_element_and_via_side(elem3, 0).element); |
| 4919 |
|
| 4920 |
EXPECT_TRUE(!graph.is_connected_elem_locally_owned(elem3, 1)); |
| 4921 |
stk::mesh::EntityId remoteElemId = 2; |
| 4922 |
EXPECT_EQ(remoteElemId, graph.get_connected_remote_id_and_via_side(elem3, 1).id); |
| 4923 |
stk::mesh::impl::ParallelInfo ¶llelInfo = graph.get_parallel_edge_info(elem3, 4, remoteElemId, 5); |
| 4924 |
EXPECT_EQ(0, parallelInfo.get_proc_rank_of_neighbor()); |
| 4925 |
EXPECT_TRUE(!remoteSkinSelector[-remoteElemId]); |
| 4926 |
|
| 4927 |
|
| 4928 |
ASSERT_EQ(1u, graph.get_num_connected_elems(elem4)); |
| 4929 |
|
| 4930 |
EXPECT_TRUE(graph.is_connected_elem_locally_owned(elem4, 0)); |
| 4931 |
EXPECT_EQ(elem3, graph.get_connected_element_and_via_side(elem4, 0).element); |
| 4932 |
} |
| 4933 |
} |
| 4934 |
} |
| 4935 |
|
| 4936 |
void test_paved_shell(stk::mesh::BulkData& bulk, stk::topology shell4) |
| 4937 |
{ |
| 4938 |
/* shell-quad-4 mesh: */ |
| 4939 |
/* */ |
| 4940 |
/* */ |
| 4941 |
/* 4*-----*3----*6 */ |
| 4942 |
/* | | | */ |
| 4943 |
/* | | | */ |
| 4944 |
/* 1*-----*2----*5 */ |
| 4945 |
/* */ |
| 4946 |
|
| 4947 |
bulk.initialize_face_adjacent_element_graph(); |
| 4948 |
stk::mesh::ElemElemGraph& graph = bulk.get_face_adjacent_element_graph(); |
| 4949 |
|
| 4950 |
stk::mesh::Part& block_1 = bulk.mesh_meta_data().declare_part_with_topology("block_1", shell4); |
| 4951 |
|
| 4952 |
bulk.modification_begin(); |
| 4953 |
stk::mesh::EntityIdVector elem1Nodes {1, 2, 3, 4}; |
| 4954 |
stk::mesh::EntityId elem1Id = 1; |
| 4955 |
stk::mesh::Entity elem1 = stk::mesh::declare_element(bulk, block_1, elem1Id, elem1Nodes); |
| 4956 |
bulk.modification_end(); |
| 4957 |
|
| 4958 |
ASSERT_EQ(1u, graph.size()); |
| 4959 |
ASSERT_EQ(0u, graph.get_num_connected_elems(elem1)); |
| 4960 |
|
| 4961 |
bulk.modification_begin(); |
| 4962 |
stk::mesh::EntityIdVector elem2Nodes {2, 5, 6, 3}; |
| 4963 |
stk::mesh::EntityId elem2Id = 2; |
| 4964 |
stk::mesh::Entity elem2 = stk::mesh::declare_element(bulk, block_1, elem2Id, elem2Nodes); |
| 4965 |
bulk.modification_end(); |
| 4966 |
|
| 4967 |
ASSERT_EQ(2u, graph.size()); |
| 4968 |
ASSERT_EQ(1u, graph.get_num_connected_elems(elem1)); |
| 4969 |
ASSERT_EQ(1u, graph.get_num_connected_elems(elem2)); |
| 4970 |
} |
| 4971 |
|
| 4972 |
TEST(ElementGraph, PavedShellFace) |
| 4973 |
{ |
| 4974 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 4975 |
|
| 4976 |
if(stk::parallel_machine_size(comm) != 1) { GTEST_SKIP(); } |
| 4977 |
|
| 4978 |
unsigned spatialDim = 3; |
| 4979 |
|
| 4980 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, comm); |
| 4981 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 4982 |
|
| 4983 |
stk::topology shell4 = stk::topology::SHELL_QUAD_4_ALL_FACE_SIDES; |
| 4984 |
test_paved_shell(bulk, shell4); |
| 4985 |
} |
| 4986 |
|
| 4987 |
TEST(ElementGraph, PavedShellEdge) |
| 4988 |
{ |
| 4989 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 4990 |
|
| 4991 |
if(stk::parallel_machine_size(comm) != 1) { GTEST_SKIP(); } |
| 4992 |
|
| 4993 |
unsigned spatialDim = 3; |
| 4994 |
|
| 4995 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, comm); |
| 4996 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 4997 |
|
| 4998 |
stk::topology shell4 = stk::topology::SHELL_QUAD_4; |
| 4999 |
test_paved_shell(bulk, shell4); |
| 5000 |
} |
| 5001 |
|
| 5002 |
TEST(ElementGraph, does_element_side_exist) |
| 5003 |
{ |
| 5004 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 5005 |
|
| 5006 |
if(stk::parallel_machine_size(comm) != 1) { GTEST_SKIP(); } |
| 5007 |
|
| 5008 |
unsigned spatialDim = 3; |
| 5009 |
|
| 5010 |
{ |
| 5011 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, comm); |
| 5012 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 5013 |
|
| 5014 |
const std::string meshDesc = |
| 5015 |
"0,1,SHELL_QUAD_4, 1,2,3,4, block_1|sideset:name=surface_1; data=1,1, 1,2, 1,3, 1,4, 1,5, 1,6; split=topology"; |
| 5016 |
|
| 5017 |
std::vector<double> coords = {0,0,0, 1,0,0, 1,1,0, 0,1,0}; |
| 5018 |
auto fullDesc = stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords); |
| 5019 |
stk::io::StkMeshIoBroker ioBroker; |
| 5020 |
ioBroker.set_enable_all_face_sides_shell_topo(true); |
| 5021 |
stk::io::fill_mesh("textmesh:" + fullDesc, bulk, ioBroker); |
| 5022 |
|
| 5023 |
stk::mesh::Entity elem1 = bulk.get_entity(stk::topology::ELEM_RANK, 1u); |
| 5024 |
stk::mesh::ConnectivityOrdinal side_ordinal = static_cast<stk::mesh::ConnectivityOrdinal>(5u); |
| 5025 |
EXPECT_TRUE(stk::mesh::impl::does_element_side_exist(bulk, elem1, side_ordinal)); |
| 5026 |
} |
| 5027 |
|
| 5028 |
{ |
| 5029 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, comm); |
| 5030 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 5031 |
|
| 5032 |
const std::string meshDesc = |
| 5033 |
"0,1,SHELL_QUAD_4, 1,2,3,4, block_1|sideset:name=surface_1; data=1,1, 1,2, 1,3, 1,4, 1,5, 1,6; split=topology"; |
| 5034 |
|
| 5035 |
std::vector<double> coords = {0,0,0, 1,0,0, 1,1,0, 0,1,0}; |
| 5036 |
auto fullDesc = stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords); |
| 5037 |
stk::io::StkMeshIoBroker ioBroker; |
| 5038 |
stk::io::fill_mesh("textmesh:" + fullDesc, bulk, ioBroker); |
| 5039 |
|
| 5040 |
stk::mesh::Entity elem1 = bulk.get_entity(stk::topology::ELEM_RANK, 1u); |
| 5041 |
stk::mesh::ConnectivityOrdinal side_ordinal = static_cast<stk::mesh::ConnectivityOrdinal>(5u); |
| 5042 |
EXPECT_TRUE(stk::mesh::impl::does_element_side_exist(bulk, elem1, side_ordinal)); |
| 5043 |
} |
| 5044 |
} |
| 5045 |
|
| 5046 |
TEST(ElementGraph, get_element_side_entries) |
| 5047 |
{ |
| 5048 |
stk::ParallelMachine comm = MPI_COMM_WORLD; |
| 5049 |
|
| 5050 |
if(stk::parallel_machine_size(comm) != 1) { GTEST_SKIP(); } |
| 5051 |
|
| 5052 |
unsigned spatialDim = 3; |
| 5053 |
|
| 5054 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, comm); |
| 5055 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 5056 |
|
| 5057 |
const std::string meshDesc = |
| 5058 |
"0,1,SHELL_QUAD_4, 1,2,3,4, block_1|sideset:name=surface_1; data=1,1, 1,3; split=topology"; |
| 5059 |
|
| 5060 |
std::vector<double> coords = {0,0,0, 1,0,0, 1,1,0, 0,1,0}; |
| 5061 |
auto fullDesc = stk::unit_test_util::get_full_text_mesh_desc(meshDesc, coords); |
| 5062 |
stk::io::StkMeshIoBroker ioBroker; |
| 5063 |
stk::io::fill_mesh("textmesh:" + fullDesc, bulk, ioBroker); |
| 5064 |
|
| 5065 |
stk::mesh::Entity elem1 = bulk.get_entity(stk::topology::ELEM_RANK, 1u); |
| 5066 |
stk::mesh::Entity face11 = bulk.get_entity(stk::topology::FACE_RANK, 11u); |
| 5067 |
stk::mesh::Entity edge13 = bulk.get_entity(stk::topology::EDGE_RANK, 13u); |
| 5068 |
|
| 5069 |
EXPECT_TRUE(bulk.is_valid(elem1)); |
| 5070 |
EXPECT_TRUE(bulk.is_valid(face11)); |
| 5071 |
EXPECT_TRUE(bulk.is_valid(edge13)); |
| 5072 |
|
| 5073 |
std::vector<stk::mesh::ElemSideOrdinal> elemSideOrdinals = stk::mesh::get_element_side_entries(bulk, elem1, false); |
| 5074 |
EXPECT_EQ(2u, elemSideOrdinals.size()); |
| 5075 |
|
| 5076 |
EXPECT_EQ(stk::mesh::ElemSideOrdinal(elem1, face11, 0), elemSideOrdinals[0]); |
| 5077 |
EXPECT_EQ(stk::mesh::ElemSideOrdinal(elem1, edge13, 2), elemSideOrdinals[1]); |
| 5078 |
} |
| 5079 |
|
| 5080 |
} // namespace |